home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #11 / Amiga Plus CD - 2004 - No. 11.iso / AmiSoft / Text / hyper / guideml.lha / GuideML / guideml.c < prev    next >
C/C++ Source or Header  |  2004-09-04  |  119KB  |  3,868 lines

  1. /***************************************************************
  2. **                                                            **
  3. **      GuideML -- Converts AmigaGuide into HTML              **
  4. **                                                            **
  5. ***************************************************************/
  6. /*
  7. **  Copyright (C) 1997-98 Richard Körber  --  All Rights Reserved
  8. **    E-Mail: shred@eratosthenes.starfleet.de
  9. **    URL:    http://shredzone.home.pages.de
  10. **
  11. ** Updated 2001-2004 by Chris Young
  12. ** chris@unsatisfactorysoftware.co.uk
  13. ** http://www.unsatisfactorysoftware.co.uk
  14. ***************************************************************/
  15. /* compile with
  16.    gcc guideml.c -o guideml -lauto -lraauto
  17.  */
  18. /*
  19. **  This program is free software; you can redistribute it and/or modify
  20. **  it under the terms of the GNU General Public License as published by
  21. **  the Free Software Foundation; either version 2 of the License, or
  22. **  any later version.
  23. **
  24. **  This program is distributed in the hope that it will be useful,
  25. **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  27. **  GNU General Public License for more details.
  28. **
  29. **  You should have received a copy of the GNU General Public License
  30. **  along with this program; if not, write to the Free Software
  31. **  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  32. **
  33. **  The author (Richard Körber) reserves the right to revoke the
  34. **  GNU General Public License whenever he feels that it is necessary,
  35. **  especially when he found out that the licence has been abused,
  36. **  ignored or violated, and without prior notice.
  37. **
  38. **  You must not use this source code to gain profit of any kind!
  39. **
  40. ***************************************************************/
  41. /*
  42. ** If you use an editor that is capable of text folding, use
  43. ** "//>" and "//<" as begin and end fold markers, respectively.
  44. */
  45.  
  46. #include <stdio.h>
  47. #include <string.h>
  48. #include <clib/alib_protos.h>
  49. #include <proto/exec.h>
  50. #include <proto/dos.h>
  51. #include <proto/gadtools.h>
  52. #include <proto/utility.h>
  53. #include <exec/lists.h>
  54. #include <exec/nodes.h>
  55. #include <exec/memory.h>
  56. #include <exec/exec.h>
  57. #include <dos/dos.h>
  58. #include <libraries/dos.h>
  59.  
  60. #include <exec/types.h>
  61. #include <exec/io.h>
  62. #include <proto/asl.h>
  63. #include <proto/intuition.h>
  64. #include <proto/window.h>
  65. #include <proto/layout.h>
  66. #include <proto/checkbox.h>
  67. #include <proto/button.h>
  68. #include <proto/label.h>
  69. #include <proto/chooser.h>
  70. #include <proto/getfile.h>
  71. #include <proto/clicktab.h>
  72. #include <proto/string.h>
  73. // #include <clib/integer_protos.h>
  74. // #include <clib/listbrowser_protos.h>
  75. #include <proto/gadtools.h>
  76. #include <proto/icon.h>
  77.  
  78. #include <intuition/intuition.h>
  79. #include <intuition/icclass.h>
  80. #include <libraries/gadtools.h>
  81. #include <workbench/icon.h>
  82.  
  83. #include <stdlib.h>
  84.  
  85. #include <classes/window.h>
  86. #include <gadgets/layout.h>
  87. #include <gadgets/checkbox.h>
  88. #include <gadgets/button.h>
  89. #include <gadgets/chooser.h>
  90. #include <gadgets/clicktab.h>
  91. // #include <gadgets/integer.h>
  92. #include <gadgets/string.h>
  93. // #include <gadgets/listbrowser.h>
  94. #include <gadgets/getfile.h>
  95. #include <images/label.h>
  96.  
  97. //#include <reaction/reaction.h>
  98. #include <reaction/reaction_macros.h>
  99.  
  100.  
  101.  
  102. #define VERSIONSTR "3.7"                 /* Version Nr */
  103. #define VERSIONDATE "04.09.2004"            /* Version Date */
  104. #define LINELEN (1024)                    /* Maximum length of a line */
  105.  
  106. struct Library *GadToolsBase;
  107. struct Library *UtilityBase;
  108.  
  109. #ifdef __amigaos4__
  110. #define __USE_INLINE__
  111. struct GadToolsIFace *IGadTools;
  112. struct UtilityIFace *IUtility;
  113. extern struct Library *DOSBase;
  114. #endif
  115.  
  116. #ifndef __amigaos4__
  117. struct Library *dosbase;
  118. struct Library *aslbase;
  119. struct Library *intuitionbase;
  120. struct Library *WindowBase;
  121. struct Library *LayoutBase;
  122. struct Library *ButtonBase;
  123. struct Library *CheckBoxBase;
  124. struct Library *LabelBase;
  125. struct Library *ChooserBase;
  126. struct Library *ClickTabBase;
  127. // struct Library *IntegerBase;
  128. struct Library *StringBase;
  129. // struct Library *ListBrowserBase;
  130. struct Library *GetFileBase;
  131. struct Library *IconBase;
  132. #endif
  133.  
  134. int err(char *,char *,int);
  135. void ui();
  136. void free_list(struct List *);
  137. void freetablist(struct List *);
  138. BOOL make_list(struct List *, UBYTE **);
  139. BOOL maketablist(struct List *, UBYTE **);
  140. void gettooltypes(); // struct WBArg *);
  141. struct Menu *addmenu(struct Window *);
  142. void cleanup(int);
  143. int wbmain(struct WBStartup *);
  144.  
  145. enum
  146. {
  147.     GID_MAIN=0,
  148.     GID_CONV,
  149.     GID_FILE,
  150.     GID_TO,
  151.     GID_HOMEURL,
  152.     GID_FINDURL,
  153.     GID_PREV,
  154.     GID_NEXT,
  155.     GID_INDEX,
  156.     GID_TOC,
  157.     GID_HELP,
  158.     GID_RETRACE,
  159.     GID_HOME,
  160.     GID_FIND,
  161.     GID_BAR,
  162.     GID_BODY,
  163.     GID_LINKS,
  164.     GID_MSDOS,
  165.     GID_SINGLEFILE,
  166.     GID_NOHTML,
  167.     GID_CSS,
  168.     GID_LA,
  169.     GID_HTMLHEADF,
  170.     GID_HTMLFOOTF,
  171.     GID_WRAP,
  172.     GID_VARWIDTH,
  173.     GID_NAVBAR,
  174.     GID_MOZNAV,
  175.     GID_IMAGES,
  176.     GID_SHOWALL,
  177.     GID_TABS,
  178.     GID_PAGE,
  179.     GID_LAST
  180. };
  181.  
  182. enum
  183. {
  184.     WID_MAIN=0,
  185.     WID_LAST
  186. };
  187.  
  188. enum
  189. {
  190.     OID_MAIN=0,
  191.     OID_LAST
  192. };
  193.  
  194. struct Gadget *gadgets[GID_LAST];
  195.  
  196. char VerStr[] = "\0$VER: GuideML "VERSIONSTR" ("VERSIONDATE")";
  197.   static unsigned char defbar[] = " | ";
  198. //    struct WBArg *wbarg;
  199.  
  200.  
  201. struct Parameter                          /* Structure of Shell parameters */
  202. {
  203.   STRPTR from;
  204.   STRPTR to;
  205.   STRPTR homeurl;
  206.   STRPTR findurl;
  207.   STRPTR prev;
  208.   STRPTR next;
  209.   STRPTR index;
  210.   STRPTR toc;
  211.   STRPTR help;
  212.   STRPTR retrace;
  213.   STRPTR home;
  214.   STRPTR find;
  215.   STRPTR bar;
  216.   STRPTR bodyext;
  217.   LONG   verbatim;
  218.   LONG   images;
  219.   LONG   footer;
  220.   STRPTR linkadd;
  221.   LONG   nolink;
  222.   LONG   noemail;
  223.   LONG   nowarn;
  224.   LONG   msdos;
  225.   LONG   singlefile;
  226.   LONG   nonavbar;
  227.   LONG   nomoznav;
  228.   LONG   showall;
  229.   STRPTR htmltoptxt;
  230.   STRPTR htmlheadf;
  231.   STRPTR htmlbottxt;
  232.   STRPTR htmlfootf;
  233.   LONG   nohtml;
  234.   STRPTR cssurl;
  235.   LONG   wordwrap;
  236.   LONG    smartwrap;
  237.   LONG   varwidth;
  238.   LONG     noauto;
  239. }param = {NULL};
  240.  
  241.   long *htmltop;
  242.   long *htmlbot;
  243.  
  244. struct text
  245. {
  246.   STRPTR from;
  247.   STRPTR to;
  248.   STRPTR prev;
  249.   STRPTR next;
  250.   STRPTR index;
  251.   STRPTR toc;
  252.   STRPTR help;
  253.   STRPTR retrace;
  254.   STRPTR home;
  255.   STRPTR find;
  256.   STRPTR bar;
  257. };
  258.  
  259. struct text textlabs;
  260.  
  261. struct Entry                              /* List of all nodes and links */
  262. {
  263.   struct MinNode link;
  264.   ULONG Count;
  265.   char Node[100];
  266.   char Prev[100];
  267.   char Next[100];
  268.   char TOC[100];
  269.   char Help[100];
  270.   char Index[100];
  271.   char Titl[100];
  272. };
  273. struct MinList entries;
  274.  
  275. struct LinkStr                            /* Link bar alternative texts */
  276. {
  277.   char Prev[100];
  278.   char Next[100];
  279.   char Index[100];
  280.   char Toc[100];
  281.   char Home[100];
  282.   char Help[100];
  283.   char Find[100];
  284.   char Retrace[100];
  285. };
  286.  
  287. char Index[100];                          /* Index page name */
  288. char Help[100];
  289.  
  290. char temp[100];
  291.  
  292. //Some dummy memory-allocating rodents for tooltype porpoises.
  293. char *ttfrom = 0;
  294. char *ttto = 0;
  295. char *tthomeurl = 0;
  296. char *ttfindurl = 0;
  297. char *ttprev = 0;
  298. char *ttnext = 0;
  299. char *ttindex = 0;
  300. char *tttoc = 0;
  301. char *tthelp = 0;
  302. char *ttretrace = 0;
  303. char *tthome = 0;
  304. char *ttfind = 0;
  305. char *ttbar = 0;
  306. char *ttbody = 0;
  307. char *ttlinkadd = 0;
  308. char *tthtmlheadf = 0;
  309. char *tthtmlfootf = 0;
  310. char *ttcss = 0;
  311.  
  312. int wb=0;
  313. int ok=0;
  314.  
  315. char defname[100];
  316.  
  317. //> UBYTE Img#?[] = {...};
  318. /*
  319. **  These are the navigation bar images, in GIF format
  320. */
  321. UBYTE ImgHome[] =
  322. {
  323.   0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
  324.   0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
  325.   0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
  326.   0x4A,0x08,0xBA,0x20,0xFC,0xB0,0x9D,0xD1,0x44,0x88,0x4B,0x9C,0x3D,0xF4,0xC5,0xDA,
  327.   0x26,0x1E,0x1F,0x14,0x8E,0x5B,0xC9,0x9C,0x28,0x69,0xB6,0x28,0x95,0x91,0x01,0x4B,
  328.   0x7B,0x73,0x70,0xD8,0x3A,0xAE,0x68,0x82,0x20,0x2A,0xE8,0x93,0xC0,0x50,0x25,0x4F,
  329.   0xED,0xC6,0x4C,0x92,0x76,0x4F,0x0F,0xD4,0x49,0x8C,0xEE,0x84,0xCE,0x51,0x0F,0x99,
  330.   0x09,0x78,0xBF,0xB4,0xAF,0x17,0x43,0x2E,0x9B,0x01,0x09,0x00,0x3B
  331.  
  332. };
  333. #define LEN_IMGHOME (0x7C)
  334.  
  335. UBYTE ImgIndex[] =
  336. {
  337.  0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
  338.  0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
  339.  0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
  340.  0x41,0x28,0xBA,0xDC,0x12,0x40,0x9C,0x49,0xAB,0x85,0xD2,0x6A,0x8A,0x4F,0xF8,0x20,
  341.  0xE8,0x05,0x53,0xE7,0x2C,0x87,0x52,0x46,0x5B,0xDB,0x85,0xF0,0xB8,0x4A,0xA7,0xAA,
  342.  0x7A,0x6C,0xAB,0xBD,0xB0,0xF8,0xCD,0xA9,0x5A,0x10,0xA8,0xBB,0xB0,0x7A,0x3E,0x12,
  343.  0x8E,0x26,0xBC,0x75,0x8A,0x95,0x27,0x74,0x86,0xAC,0x42,0x00,0xD8,0xAC,0x76,0x9B,
  344.  0x4D,0x00,0x00,0x3B
  345.  
  346.  
  347. };
  348. #define LEN_IMGINDEX (0x73)
  349.  
  350. UBYTE ImgNext[] =
  351. {
  352.  0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
  353.  0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
  354.  0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
  355.  0x33,0x08,0xBA,0x2A,0xFC,0xB0,0x8D,0x48,0x81,0x38,0xB3,0xBE,0x8B,0x35,0xE3,0xDD,
  356.  0x27,0x8C,0xE4,0x78,0x9C,0x61,0x83,0xAE,0x6C,0x0A,0xB6,0x6C,0xA0,0xC2,0xF1,0x22,
  357.  0x04,0x78,0x8E,0xAF,0xB2,0x07,0xF6,0xBE,0x13,0x30,0x38,0xF4,0x15,0x7D,0x9E,0xA4,
  358.  0x72,0xA9,0x4C,0x00,0x00,0x3B
  359.  
  360.  
  361. };
  362. #define LEN_IMGNEXT (0x65)
  363.  
  364. UBYTE ImgPrev[] =
  365. {
  366.  0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
  367.  0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
  368.  0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
  369. 0x37,0x08,0xBA,0x10,0xFC,0x10,0x08,0x17,0xA3,0x38,0xB4,0xB2,0x8B,0xF5,0x3E,0x60,
  370. 0xA6,0x71,0xA0,0x60,0x9E,0xE7,0x42,0x82,0x6C,0xDB,0x01,0x83,0x2B,0xB3,0x59,0x3C,
  371. 0xBB,0xA2,0x1D,0x06,0x7C,0xCF,0x3F,0x3A,0x91,0xC7,0x26,0x1C,0xBE,0x3C,0x8C,0x41,
  372. 0x11,0xB9,0x44,0x3A,0x9F,0xD0,0x48,0x02,0x00,0x3B
  373.  
  374.  
  375. };
  376. #define LEN_IMGPREV (0x69)
  377.  
  378. UBYTE ImgTOC[] =
  379. {
  380.  0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
  381.  0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
  382.  0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
  383. 0x34,0x08,0xBA,0x20,0xFC,0xB0,0x9D,0x11,0xA3,0x38,0x98,0xD6,0x75,0x71,0xDE,0x92,
  384. 0xE7,0x69,0x50,0x27,0x8E,0xE5,0xA9,0x92,0x4D,0xE0,0xBA,0xDE,0xFB,0x56,0x66,0x00,
  385. 0x72,0xF1,0xAD,0xD4,0x7A,0x78,0xD8,0x3A,0x5E,0x30,0x37,0xC4,0x00,0x6F,0x02,0x59,
  386. 0x6F,0xC9,0x54,0x24,0x00,0x00,0x3B
  387. };
  388. #define LEN_IMGTOC (0x66)
  389.  
  390. // below are temporary images
  391. UBYTE ImgHelp[] =
  392. {
  393.  0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
  394.  0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
  395.  0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
  396. 0x36,0x08,0x2A,0xDC,0x32,0x2A,0x4A,0x71,0xAA,0xAD,0x50,0xAE,0xCB,0x4F,0xD0,0x00,
  397. 0x15,0x8C,0x24,0xE5,0x69,0xE6,0x37,0x55,0x6A,0x94,0xAE,0x27,0x28,0xB4,0x21,0x0B,
  398. 0xDE,0xEF,0x2D,0xC7,0x3A,0x4C,0xF7,0x0A,0x1E,0x70,0x08,0x64,0x10,0x5D,0xB6,0x63,
  399. 0xEE,0x38,0x3A,0x3A,0x9F,0x92,0x04,0x00,0x3B
  400.  
  401. };
  402. #define LEN_IMGHELP (0x68)
  403.  
  404. UBYTE ImgFind[] =
  405. {
  406.  0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
  407.  0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
  408.  0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
  409. 0x42,0x08,0x0A,0xD2,0xBD,0x30,0x8A,0x43,0xE9,0x88,0x92,0x86,0x6D,0xB1,0x9A,0x47,
  410. 0xB0,0x0C,0x5D,0x16,0x46,0xE4,0x09,0x4D,0x22,0xC6,0x66,0x2D,0x2C,0xBB,0xEA,0x02,
  411. 0x5E,0xAB,0x86,0xA5,0x38,0xA3,0x7B,0x29,0x47,0xE5,0xD0,0x43,0x0D,0x43,0x95,0x22,
  412. 0x64,0xC3,0x04,0xA4,0x88,0x1E,0x60,0x32,0xBA,0xFB,0x51,0x21,0x83,0xCD,0x75,0xCB,
  413. 0x8D,0x24,0x00,0x00,0x3B
  414.  
  415. };
  416. #define LEN_IMGFIND (0x74)
  417.  
  418. UBYTE ImgRetrace[] =
  419. {
  420.  0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
  421.  0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
  422.  0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
  423. 0x42,0x28,0x02,0xA0,0xCE,0x30,0x8A,0xA3,0x8E,0xB5,0x6A,0x44,0x36,0xAF,0xBF,0x9A,
  424. 0x74,0x05,0x24,0xE9,0x85,0xDC,0x18,0x0D,0xA0,0x54,0x92,0x6B,0xBB,0xCD,0xE9,0x11,
  425. 0xD0,0x74,0x77,0xE3,0x9B,0xCE,0xF7,0x96,0x5D,0x43,0x91,0x0B,0x8A,0x0E,0xA8,0x9A,
  426. 0xED,0x48,0x71,0x74,0x96,0x1B,0xD6,0x47,0x45,0x33,0x79,0x60,0xBF,0x97,0xF0,0xC7,
  427. 0xED,0xF2,0x12,0x00,0x3B
  428.  
  429. };
  430. #define LEN_IMGRETRACE (0x74)
  431.  
  432. //<
  433.  
  434. //> STRPTR entity[96] = {...};
  435. /*
  436. ** This are the full names of all HTML entities
  437. */
  438. STRPTR entity[96] =
  439. {
  440.   "nbsp","iexcl","cent","pound","curren","yen","brvbar","sect","uml",
  441.   "copy","ordf","laquo","not","shy","reg","macr","deg","plusmn","sup2",
  442.   "sup3","acute","micro","para","middot","cedil","sup1","ordm","raquo",
  443.   "frac14","frac12","frac34","iquest","Agrave","Aacute","Acirc","Atilde",
  444.   "Auml","Aring","AElig","Ccedil","Egrave","Eacute","Ecirc","Euml","Igrave",
  445.   "Iacute","Icirc","Iuml","ETH","Ntilde","Ograve","Oacute","Ocirc","Otilde",
  446.   "Ouml","times","Oslash","Ugrave","Uacute","Ucirc","Uuml","Yacute","THORN",
  447.   "szlig","agrave","aacute","acirc","atilde","auml","aring","aelig","ccedil",
  448.   "egrave","eacute","ecirc","euml","igrave","iacute","icirc","iuml","eth",
  449.   "ntilde","ograve","oacute","ocirc","otilde","ouml","divide","oslash",
  450.   "ugrave","uacute","ucirc","uuml","yacute","thorn","yuml"
  451. };
  452. //<
  453. //> STRPTR agpens[] , htmlpens[]
  454. /*
  455. ** This are the pen names in AmigaGuide documents
  456. */
  457. STRPTR agpens[] =
  458. {
  459.   "text}","shine}","shadow}","fill}","filltext}","background}","highlight}",
  460.   NULL
  461. };
  462.  
  463. /*
  464. ** And this are the appropriate HTML colors
  465. */
  466. STRPTR htmlpens[] =
  467. {
  468.   "#000000","#ffffff","#000000","#3864a0","#000000","#949494","#ffffff"
  469. };
  470.  
  471. STRPTR cssclass[] =
  472. {
  473.   "agtext","agshine","agshadow","agfill","agfilltext","agbackground","aghighlight"
  474. };
  475. //<
  476.  
  477. //> SaveImg()
  478. /*------------------------------------------------------------*
  479. *   SaveImg()        Saves one image                          *
  480. *     -> file File Name                                       *
  481. *     -> data Data buffer                                     *
  482. *     -> len  Length                                          *
  483. *     <-      Success                                         *
  484. */
  485. LONG SaveImg(STRPTR file, UBYTE *data, ULONG len)
  486. {
  487.   BPTR lock;
  488.  
  489.   if(lock = Lock(file,ACCESS_READ))       // Already existing?
  490.   {
  491.     UnLock(lock);
  492.     return(1);                            // then leave with success
  493.   }
  494.  
  495.   if(param.verbatim) printf("Creating image '%s'\n",file);  // Report
  496.  
  497.   if(lock = Open(file,MODE_NEWFILE))      // Open the image file
  498.   {
  499.     if(-1 == Write(lock,data,len))        // Write the image
  500.     {
  501.       Close(lock);                        // Write failed, so
  502.       return(0);                          // return without success
  503.     }
  504.     Close(lock);                          // Write succeeded, so
  505.     return(1);                            // return with success
  506.   }
  507.   return(0);                              // No lock, no success
  508. }
  509. //<
  510. //> SaveImages()
  511. /*------------------------------------------------------------*
  512. *   SaveImages()     Saves all required images                *
  513. *     <-      Success                                         *
  514. */
  515. LONG SaveImages(void)
  516. {
  517.   for(;;)
  518.   {
  519.     if(param.homeurl)
  520.       if(!SaveImg("home.gif" ,ImgHome ,LEN_IMGHOME )) break;
  521.     if(param.retrace)
  522.       if(!SaveImg("retrace.gif" ,ImgRetrace ,LEN_IMGRETRACE )) break;
  523.     if(param.help)
  524.       if(!SaveImg("help.gif" ,ImgHelp ,LEN_IMGHELP )) break;
  525.     if(param.findurl)
  526.       if(!SaveImg("find.gif" ,ImgFind ,LEN_IMGFIND )) break;
  527.  
  528. //    if(*Index)
  529.       if(!SaveImg("index.gif",ImgIndex,LEN_IMGINDEX)) break;
  530.  
  531.     if(!SaveImg("next.gif" ,ImgNext ,LEN_IMGNEXT )) break;
  532.     if(!SaveImg("prev.gif" ,ImgPrev ,LEN_IMGPREV )) break;
  533.     if(!SaveImg("toc.gif"  ,ImgTOC  ,LEN_IMGTOC  )) break;
  534.     return(1);
  535.   }
  536.   return(0);
  537. }
  538. //<
  539.  
  540. //> CopyLink()
  541. /*------------------------------------------------------------*
  542. *   CopyLink()       Copies a link file name into a variable  *
  543. *     -> link Link                                            *
  544. *     -> var  String-Var                                      *
  545. */
  546. void CopyLink(STRPTR link, STRPTR var)
  547. {
  548.   char ch;
  549.  
  550.   var[0] = '\0';                          // Init
  551.  
  552.     strcpy(var,param.linkadd);
  553.     var=var+strlen(param.linkadd);
  554.  
  555.   while(*link && *link==' ') link++;      // Suppress spaces
  556.   if(!*link) return;                      //   there were only spaces!
  557.  
  558.   if(*link != '\"')
  559.   {                                       // Quick Mode
  560.     while((ch = *link++)!=' ' && ch!='\n')
  561.     {
  562.       if(ch==':') ch='/'; // colon to slash again
  563.       if(ch>='A' && ch<='Z') ch+=32; // upper to lower again
  564.       *var++ = ch;
  565.     }
  566.   }
  567.   else
  568.   {                                       // Quote Mode
  569.     link++;                               //   we had a leading quote
  570.     if(!*link) return;
  571.     while((ch = *link++)!='\"' && ch!='\n')
  572.     {
  573.       if(ch==' ') ch = '_'; // space converts to underscore
  574.       if(ch==':') ch = '/'; // colon converts to slash
  575.       if(ch>='A' && ch<='Z') ch+=32; // uppercase converts to lowercase
  576.       *var++ = ch;
  577.     }
  578.   }
  579.  
  580.   *var++ = '.';                           // Add html suffix
  581.   *var++ = 'h';
  582.   *var++ = 't';
  583.   *var++ = 'm';
  584.   if(!param.msdos) *var++ = 'l';
  585.   *var = '\0';
  586. }
  587. //<
  588. //> MyPutCh()
  589. /*------------------------------------------------------------*
  590. *   MyPutCh()       Writes single chars into HTML             *
  591. *     -> fh   output file handle                              *
  592. *     -> ch   Amiga char to be written                        *
  593. *     <-      -1 for failure                                  *
  594. */
  595. LONG MyPutCh(BPTR fh, unsigned char ch)
  596. {
  597.   if(ch<' ' && ch!='\n')                // Is it a control char?
  598.   {
  599.     return FPrintf(fh,"&#%03ld;",ch);   //   yes: return them as number
  600.   }
  601.   else if(ch < 128)                     // Is it an ASCII char?
  602.   {
  603.     if(ch=='\"') return FPuts(fh,""");     // Convert some exceptions
  604.     else if(ch=='&') return FPuts(fh,"&");
  605.     else if(ch=='<') return FPuts(fh,"<");   // #060
  606.     else if(ch=='>') return FPuts(fh,">"); // #062
  607.     else return FPutC(fh,ch);                   // else put char directly
  608.   }
  609.   else                                  // Chars >127 ?
  610.   {
  611.     if(ch>=160)                         // Do we have an entity name?
  612.       return FPrintf(fh,"&%s;",entity[ch-160]); // yes: use this one
  613.     else
  614.       return FPrintf(fh,"&#%03ld;",ch);         // no: use it's number
  615.   }
  616. }
  617. //<
  618. //> MyPuts()
  619. /*------------------------------------------------------------*
  620. *   MyPuts()        Writes a string into HTML                 *
  621. *     -> fh   Output file handle                              *
  622. *     -> str  String to be output                             *
  623. *     <-      -1 for failure                                  *
  624. */
  625. LONG MyPuts(BPTR fh, STRPTR str)
  626. {
  627.   unsigned char ch;
  628.  
  629.   while(ch = *str++)                        // go through the string
  630.   {
  631.     if(ch=='\"' || ch=='<' || ch=='>' || ch=='&')      // do NOT convert them
  632.     {                                       //  since they are also used
  633.       if(-1 == FPutC(fh,ch)) return(-1);    //  in HTML tags
  634.     }
  635.     else
  636.     {
  637.       if(-1 == MyPutCh(fh,ch)) return(-1);
  638.     }
  639.   }
  640.   return(0);
  641. }
  642. //<
  643. //> ConvLine()
  644. /*------------------------------------------------------------*
  645. *   ConvLine()      Converts an AmigaGuide line               *
  646. *     -> fh   output file handle                              *
  647. *     -> buf  Source buffer                                   *
  648. *     -> linenr line number                                   *
  649. *     <-      Success                                         *
  650. */
  651. LONG ConvLine(BPTR fh, STRPTR buf, ULONG linenr)
  652. {
  653.   unsigned char ch;
  654.   char linkstr[100];
  655.   register UWORD dolink  = !param.nolink;
  656.   register UWORD doemail = !param.noemail;
  657.  
  658. if((param.smartwrap) && (strlen(buf)<2))
  659.     {
  660.     if(-1 == FPuts(fh,"<br>")) return(0);
  661.     }
  662.  
  663.   while(ch = *buf++)                      // while chars available
  664.   {
  665.     if('\\'==ch)                          //   backslash escape character?
  666.     {
  667.       switch(*buf)
  668.       {
  669.         case '\\':                        // '\\' -> '\'
  670.         case '@':                         // '\@' -> '@'
  671.           if(-1 == MyPutCh(fh,*buf)) return(0);
  672.           buf++;
  673.           break;
  674.       }
  675.       continue;
  676.     }
  677.  
  678.     if(doemail)                           // email recognition activated?
  679.     {
  680.       if(  (ch>='a' && ch<='z')           // Could this be a valid email?
  681.          ||(ch>='A' && ch<='Z')
  682.          ||(ch>='0' && ch<='9'))
  683.       {
  684.         UWORD length   = 0;   // length of the email string
  685.         UWORD atfound  = 0;   // how many '@' were found?
  686.         UWORD charcnt  = 0;   // how many characters in total?
  687.         UWORD dotfound = 0;   // how many dots?
  688.         UWORD atdot    = 0;   // how many dots after the '@'?
  689.         UWORD chardot  = 0;   // how many chars after the last dot?
  690.         STRPTR index   = --buf;
  691.         UWORD i;
  692.         unsigned char ech;
  693.  
  694.         while(ech = *index++)
  695.         {
  696.           if(   !(ech>='a' && ech<='z')   // still a valid email char?
  697.              && !(ech>='A' && ech<='Z')
  698.              && !(ech>='0' && ech<='9')
  699.              && !(ech=='@' || ech=='.' || ech=='_' || ech=='-')) break;
  700.           length++;
  701.           if(ech=='@')                    // count '@'
  702.           {
  703.             if(*index=='{')               // is it an AmigaGuide attribute?
  704.             {
  705.               length--;                   //   exclude the '@'
  706.               break;                      //   the address is finished
  707.             }
  708.             atfound++;
  709.             atdot = 0;
  710.             continue;
  711.           }
  712.           if(ech=='.')                    // count '.'
  713.           {
  714.             dotfound++;
  715.             atdot++;
  716.             chardot = 0;
  717.             continue;
  718.           }
  719.           charcnt++;                      // one more char
  720.           chardot++;
  721.         }
  722.         if(   atfound==1                  // exactly one '@'
  723.            && dotfound>0                  // at least one '.' (domain.country)
  724.            && atdot>0                     //   this dot must be after the '@'
  725.            && chardot>=2 && chardot<=4    // domain must have two or three chars
  726.            && charcnt>6)                  // and we have also some chars
  727.         {
  728.           if(-1 == FPuts(fh,"<a href=\"mailto:")) return(0);  // Generate email link
  729.           for(i=0;i<length;i++)
  730.           {
  731.             if(-1 == FPutC(fh,buf[i])) return(0);
  732.           }
  733.           if(-1 == FPuts(fh,"\">")) return(0);
  734.           for(;length;length--)
  735.           {
  736.             if(-1 == FPutC(fh,*buf++)) return(0);
  737.           }
  738.           if(-1 == FPuts(fh,"</a>")) return(0);
  739.           continue;
  740.         }
  741.         buf++;
  742.       }
  743.     }
  744.  
  745.     if(dolink)                            // internet link recognition
  746.     {
  747.       if(  (!Strnicmp(buf-1,"ftp://"  ,6))    // ftp://... - Link ?
  748.          ||(!Strnicmp(buf-1,"gopher:" ,7))    // gopher:... - Link ?
  749.          ||(!Strnicmp(buf-1,"http://" ,7))    // http://... - Link ?
  750.          ||(!Strnicmp(buf-1,"https://",8))    // https://... - Link ?
  751.          ||(!Strnicmp(buf-1,"mailto:" ,7))    // mailto:... - Link ?
  752.          ||(!Strnicmp(buf-1,"news:"   ,5))    // news:... - Link ?
  753.          ||(!Strnicmp(buf-1,"nntp:"   ,5))    // nntp:... - Link ?
  754.          ||(!Strnicmp(buf-1,"telnet:" ,7))    // telnet:... - Link ?
  755.          ||(!Strnicmp(buf-1,"www."    ,4)))   // www. - Link?
  756.       {
  757.         STRPTR bufstart;
  758.  
  759.         if(-1 == FPuts(fh,"<a href=\"")) return(0);
  760.  
  761.         if(!Strnicmp(buf-1,"www.",4))
  762.           if(-1 == FPuts(fh,"http://")) return(0);
  763.  
  764.         bufstart = --buf;
  765.         while(ch = *buf++)
  766.         {
  767.           if(' '==ch || '\n'==ch || ')'==ch || ('@'==ch && '{'==*buf)) break;
  768.           if(-1 == FPutC(fh,ch)) return(0);
  769.         }
  770.         if(-1 == FPuts(fh,"\">")) return(0);
  771.         for(;bufstart<buf-1;bufstart++)     // followed by a verbatim copy
  772.         {
  773.           if(-1 == FPutC(fh,*bufstart)) return(0);
  774.         }
  775.         if(-1 == FPuts(fh,"</a>")) return(0);
  776.       }
  777.     }
  778.  
  779.     if('@'==ch && '{'==*buf)              // AmigaGuide command?
  780.     {
  781.       buf++;                              // read the command?
  782.       for(;;)
  783.       {
  784.         if('\"' == *buf)                  // is it a link?
  785.         {
  786.           STRPTR link;
  787.           UWORD  linkpos=0;
  788.           BOOL   linkquot=0;
  789.  
  790.           buf++;                          // skip the quotation marks
  791.           link = buf;
  792.           while(*link && *link!='\"') link++;
  793.           if(!*link) return(0);
  794.           link++;
  795.           while(*link && (*link==' ' || *link==',' || *link=='\t')) link++;
  796.           if(!*link) return(0);
  797.           if(Strnicmp(link,"link",4))
  798.           {                               // this is NO link command!
  799.             if(-1 == FPuts(fh,"<u>")) return(0);
  800.             while((ch = *buf++) != '\"')
  801.               if(-1 == MyPutCh(fh,ch)) return(0);
  802.             if(-1 == FPuts(fh,"</u>")) return(0);
  803.             buf = link;
  804.             while(*buf && *buf!=' ') buf++;
  805.             *buf++ = '\0';
  806.             if(!param.nowarn) printf("Line %ld: WARNING: '%s' command skipped!\n",linenr,link);
  807.             while(*buf && *buf!='}') buf++;
  808.             if(*buf =='}') buf++;
  809.             break;
  810.           }
  811.           link+=4;
  812.           while(*link && *link==' ') link++;
  813.           if(!*link) return(0);
  814.           if(*link == '\"')
  815.           {
  816.             link++;
  817.             linkquot=1;
  818.           }
  819.           while(*link && *link!='}')
  820.           {
  821.             ch = *link++;
  822.             if(ch=='\"' && linkquot) break;
  823.             if(ch==' ' && !linkquot) break;
  824.             if(ch>='A' && ch<='Z') ch+=32;
  825.             linkstr[linkpos++] = (ch==' ' || ch==':' ? '_' : ch);
  826.           }
  827.           while(*link && *link!='}') link++;
  828.           while(linkpos>0 && linkstr[linkpos-1] == '_') linkpos--;
  829.           if(linkstr[linkpos-1] == '\"') linkpos--;
  830.           linkstr[linkpos] = '\0';
  831.           if(!*link) return(0);
  832.           link++;
  833.           if(-1 == FPuts(fh,"<a href=\"")) return(0);
  834.           if(param.linkadd)
  835.           {
  836.             if(-1 == FPuts(fh,param.linkadd)) return(0);
  837.           }
  838.           if(-1 == FPuts(fh,linkstr)) return(0);
  839.           if(param.msdos)
  840.           {
  841.             if(-1 == FPuts(fh,".htm\">")) return(0);
  842.           }
  843.           else
  844.           {
  845.             if(-1 == FPuts(fh,".html\">")) return(0);
  846.           }
  847.           while((ch = *buf++) != '\"')
  848.             if(-1 == MyPutCh(fh,ch)) return(0);
  849.           if(-1 == FPuts(fh,"</a>")) return(0);
  850.           buf = link;
  851.           break;
  852.         }
  853.  
  854.         if(!Strnicmp(buf,"b}",2))         // @{B}
  855.         {
  856.           if(-1 == FPuts(fh,"<b>")) return(0);
  857.           buf += 2;
  858.           break;
  859.         }
  860.         if(!Strnicmp(buf,"ub}",3))        // @{UB}
  861.         {
  862.           if(-1 == FPuts(fh,"</b>")) return(0);
  863.           buf += 3;
  864.           break;
  865.         }
  866.  
  867.         if(!Strnicmp(buf,"i}",2))         // @{I}
  868.         {
  869.           if(-1 == FPuts(fh,"<i>")) return(0);
  870.           buf += 2;
  871.           break;
  872.         }
  873.         if(!Strnicmp(buf,"ui}",3))        // @{UI}
  874.         {
  875.           if(-1 == FPuts(fh,"</i>")) return(0);
  876.           buf += 3;
  877.           break;
  878.         }
  879.  
  880.         if(!Strnicmp(buf,"u}",2))         // @{U}
  881.         {
  882.           if(-1 == FPuts(fh,"<u>")) return(0);
  883.           buf += 2;
  884.           break;
  885.         }
  886.         if(!Strnicmp(buf,"uu}",3))        // @{UU}
  887.         {
  888.           if(-1 == FPuts(fh,"</u>")) return(0);
  889.           buf += 3;
  890.           break;
  891.         }
  892.         if(!Strnicmp(buf,"code}",3))        // @{CODE}
  893.         {
  894.           if(-1 == FPuts(fh,"<pre>")) return(0);
  895.           buf += 5;
  896.           break;
  897.         }
  898.         if(!Strnicmp(buf,"body}",3))        // @{BODY}
  899.         {
  900.           if(-1 == FPuts(fh,"</pre>")) return(0);
  901.           buf += 5;
  902.           break;
  903.         }
  904.         if(!Strnicmp(buf,"line}",3))        // @{LINE}
  905.         {
  906.           if(-1 == FPuts(fh,"<br>")) return(0);
  907.           buf += 5;
  908.           break;
  909.         }
  910.         if(!Strnicmp(buf,"par}",3))        // @{PAR}
  911.         {
  912.           if(-1 == FPuts(fh,"<p>")) return(0);
  913.           buf += 4;
  914.           break;
  915.         }
  916.         if(!Strnicmp(buf,"plain}",3))        // @{PLAIN}
  917.         {
  918.           if(-1 == FPuts(fh,"</b></i></u>")) return(0);
  919.           buf += 6;
  920.           break;
  921.         }
  922.         if(!Strnicmp(buf,"jcenter}",3))        // @{JCENTER}
  923.         {
  924.           if(-1 == FPuts(fh,"<p align=\"center\">")) return(0);
  925.           buf += 8;
  926.           break;
  927.         }
  928.         if(!Strnicmp(buf,"jleft}",3))        // @{JLEFT}
  929.         {
  930.           if(-1 == FPuts(fh,"<p align=\"left\">")) return(0);
  931.           buf += 6;
  932.           break;
  933.         }
  934.         if(!Strnicmp(buf,"jright}",3))        // @{JRIGHT}
  935.         {
  936.           if(-1 == FPuts(fh,"<p align=\"right\">")) return(0);
  937.           buf += 7;
  938.           break;
  939.         }
  940.  
  941.         if(!Strnicmp(buf,"fg ",3))        // @{FG ...}
  942.         {
  943.           UWORD i=0;
  944.           buf += 3;
  945.  
  946.           while(*buf == ' ') buf++;
  947.  
  948.           while(agpens[i])
  949.           {
  950.             if(!Strnicmp(buf,agpens[i],strlen(agpens[i])))
  951.             {
  952.               if(-1 == FPrintf(fh,"<font color=\"%s\" class=\"%s\">",htmlpens[i],cssclass[i])) return(0);
  953.               buf += strlen(agpens[i]);
  954.               break;
  955.             }
  956.             i++;
  957.           }
  958.           if(agpens[i]) break;
  959.         }
  960.  
  961.         while(*buf && *buf!='}') buf++;   // Skip an unknown command!
  962.         buf++;
  963.         break;
  964.       }
  965.  
  966.     }
  967.     else
  968.       if(-1 == MyPutCh(fh,ch)) return(0); // Error!
  969.   }
  970.   return(1);
  971. }
  972. //<
  973.  
  974. //> NavBar()
  975. /*------------------------------------------------------------*
  976. *   NavBar()        Produces the navigation bar               *
  977. *     -> tfh   output file handle                             *
  978. *     -> enode node with link data                            *
  979. *     <-      Success                                         *
  980. */
  981. LONG NavBar(BPTR tfh, struct Entry *enode)
  982. {
  983.   short before = 0;
  984.   char main[100];
  985.  
  986.   for(;;)
  987.   {
  988.  
  989.     if(param.homeurl)
  990.     {
  991.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  992.       if(-1 == FPrintf(tfh,"<a href=\"%s\">",param.homeurl)) break;
  993.       if(-1 == MyPuts(tfh,param.home)) break;
  994.       if(-1 == FPuts(tfh,"</a>")) break;
  995.         before = 1;
  996.     }
  997.  
  998.  
  999.     if(enode->Count)            // main page does not have a TOC link
  1000.     {
  1001.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1002.  
  1003. strcpy(main,param.linkadd);
  1004.  
  1005.       if(param.msdos)
  1006.       {
  1007.         strcat(main,"main.htm");
  1008.         if(-1 == FPrintf(tfh,"<a href=\"%s\">",(*enode->TOC ? enode->TOC : main))) break;
  1009.       }
  1010.       else
  1011.       {
  1012.         strcat(main,"main.html");
  1013.         if(-1 == FPrintf(tfh,"<a href=\"%s\">",(*enode->TOC ? enode->TOC : main))) break;
  1014.       }
  1015.       if(-1 == MyPuts(tfh,param.toc)) break;
  1016.       if(-1 == FPuts(tfh,"</a>")) break;
  1017.       before = 1;
  1018.     }
  1019.     else if(param.showall)
  1020.     {
  1021.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1022.       if(-1 == MyPuts(tfh,param.toc)) break;
  1023.       before = 1;
  1024.     }
  1025.  
  1026.     if(*enode->Index)
  1027.     {
  1028.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1029.       if(-1 == FPrintf(tfh,"<a href=\"%s\">",enode->Index)) break;
  1030.       if(-1 == MyPuts(tfh,param.index)) break;
  1031.       if(-1 == FPuts(tfh,"</a>")) break;
  1032.       before = 1;
  1033.     }
  1034.     else if(*Index)
  1035.     {
  1036.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1037.       if(-1 == FPrintf(tfh,"<a href=\"%s\">",Index)) break;
  1038.       if(-1 == MyPuts(tfh,param.index)) break;
  1039.       if(-1 == FPuts(tfh,"</a>")) break;
  1040.       before = 1;
  1041.     }
  1042.     else if(param.showall)
  1043.     {
  1044.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1045.       if(-1 == MyPuts(tfh,param.index)) break;
  1046.       before = 1;
  1047.     }
  1048.  
  1049.     if(*enode->Help)
  1050.     {
  1051.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1052.       if(-1 == FPrintf(tfh,"<a href=\"%s\">",enode->Help)) break;
  1053.       if(-1 == MyPuts(tfh,param.help)) break;
  1054.       if(-1 == FPuts(tfh,"</a>")) break;
  1055.       before = 1;
  1056.     }
  1057.     else if(*Help)
  1058.     {
  1059.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1060.       if(-1 == FPrintf(tfh,"<a href=\"%s\">",Help)) break;
  1061.       if(-1 == MyPuts(tfh,param.help)) break;
  1062.       if(-1 == FPuts(tfh,"</a>")) break;
  1063.       before = 1;
  1064.     }
  1065.     else if(param.showall)
  1066.     {
  1067.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1068. //      if(-1 == FPrintf(tfh,"<a href=\"http://www.unsatisfactorysoftware.co.uk/guideml/help.guide/main.html\">",Help)) break;
  1069.       if(-1 == MyPuts(tfh,param.help)) break;
  1070. //      if(-1 == FPuts(tfh,"</a>")) break;
  1071.       before = 1;
  1072.     }
  1073.  
  1074.     if(param.retrace)
  1075.     {
  1076.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1077.       if(-1 == MyPuts(tfh,"<a href=\"javascript:window.history.go(-1)\">")) break;
  1078.       if(-1 == MyPuts(tfh,param.retrace)) break;
  1079.       if(-1 == FPuts(tfh,"</a>")) break;
  1080.       before = 1;
  1081.     }
  1082.  
  1083.     if(*enode->Prev)
  1084.     {
  1085.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1086.       if(-1 == FPrintf(tfh,"<a href=\"%s\">",enode->Prev)) break;
  1087.       if(-1 == MyPuts(tfh,param.prev)) break;
  1088.       if(-1 == FPuts(tfh,"</a>")) break;
  1089.       before = 1;
  1090.     }
  1091.     else
  1092.     {
  1093.       struct Entry *pred = (struct Entry *)enode->link.mln_Pred;
  1094.       if(pred->link.mln_Pred)
  1095.       {
  1096.         if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1097.         if(-1 == FPrintf(tfh,"<a href=\"%s\">",pred->Node)) break;
  1098.         if(-1 == MyPuts(tfh,param.prev)) break;
  1099.         if(-1 == FPuts(tfh,"</a>")) break;
  1100.         before = 1;
  1101.       }
  1102.       else if(param.showall)
  1103.       {
  1104.         if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1105.         if(-1 == MyPuts(tfh,param.prev)) break;
  1106.         before = 1;
  1107.       }
  1108.  
  1109.     }
  1110.  
  1111.     if(*enode->Next)
  1112.     {
  1113.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1114.       if(-1 == FPrintf(tfh,"<a href=\"%s\">",enode->Next)) break;
  1115.       if(-1 == MyPuts(tfh,param.next)) break;
  1116.       if(-1 == FPuts(tfh,"</a>")) break;
  1117.       before = 1;
  1118.     }
  1119.     else
  1120.     {
  1121.       struct Entry *next = (struct Entry *)enode->link.mln_Succ;
  1122.       if(next->link.mln_Succ)
  1123.       {
  1124.         if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1125.         if(-1 == FPrintf(tfh,"<a href=\"%s\">",next->Node)) break;
  1126.         if(-1 == MyPuts(tfh,param.next)) break;
  1127.         if(-1 == FPuts(tfh,"</a>")) break;
  1128.         before = 1;
  1129.       }
  1130.       else if(param.showall)
  1131.       {
  1132.         if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1133.         if(-1 == MyPuts(tfh,param.next)) break;
  1134.         before = 1;
  1135.       }
  1136.  
  1137.     }
  1138.     if(param.findurl)
  1139.     {
  1140.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1141.       if(-1 == FPrintf(tfh,"<a href=\"%s\">",param.findurl)) break;
  1142.       if(-1 == MyPuts(tfh,param.find)) break;
  1143.       if(-1 == FPuts(tfh,"</a>")) break;
  1144.       before = 1;
  1145.     }
  1146.  
  1147.  
  1148.     if(-1 == FPutC(tfh,'\n')) break;
  1149.     return(1);                            // ALL OK
  1150.   }
  1151.   return(0);                              // ERROR
  1152. }
  1153. //<
  1154.  
  1155. //> MozNavBar()
  1156. /*--------------------------------------------------------------------*
  1157. *   MozNavBar() Produces a Mozilla-compatible site navigation bar     *
  1158. *     -> tfh   output file handle                                     *
  1159. *     -> enode node with link data                                    *
  1160. *     <-      Success                                                 *
  1161. */
  1162. LONG MozNavBar(BPTR tfh, struct Entry *enode)
  1163. {
  1164.   short before = 0;
  1165.  
  1166.   for(;;)
  1167.   {
  1168.     if(enode->Count)            // main page does not have a TOC link
  1169.     {
  1170.       if(param.msdos)
  1171.       {
  1172.         if(-1 == FPrintf(tfh,"<link rel=\"up\" href=\"%s\" title=\"%s\" />\n",(*enode->TOC ? enode->TOC : "main.htm"),textlabs.toc)) break;
  1173.       }
  1174.       else
  1175.       {
  1176.         if(-1 == FPrintf(tfh,"<link rel=\"up\" href=\"%s\" title=\"%s\" />\n",(*enode->TOC ? enode->TOC : "main.html"),textlabs.toc)) break;
  1177.       }
  1178.     }
  1179.  
  1180.     if(*enode->Index)
  1181.     {
  1182.       if(-1 == FPrintf(tfh,"<link rel=\"index\" href=\"%s\" title=\"%s\" />\n",enode->Index,textlabs.index)) break;
  1183.     }
  1184.     else if(*Index)
  1185.     {
  1186.       if(-1 == FPrintf(tfh,"<link rel=\"index\" href=\"%s\" title=\"%s\" />\n",Index,param.index)) break;
  1187.     }
  1188.  
  1189.     if(*enode->Prev)
  1190.     {
  1191.       if(-1 == FPrintf(tfh,"<link rel=\"previous\" href=\"%s\" title=\"%s\" />\n",enode->Prev,textlabs.prev)) break;
  1192.     }
  1193.     else
  1194.     {
  1195.       struct Entry *pred = (struct Entry *)enode->link.mln_Pred;
  1196.       if(pred->link.mln_Pred)
  1197.       {
  1198.         if(-1 == FPrintf(tfh,"<link rel=\"previous\" href=\"%s\" title=\"%s\" />\n",pred->Node,textlabs.prev)) break;
  1199.       }
  1200.     }
  1201.  
  1202.     if(*enode->Next)
  1203.     {
  1204.       if(-1 == FPrintf(tfh,"<link rel=\"next\" href=\"%s\" title=\"%s\" />\n",enode->Next,textlabs.next)) break;
  1205.     }
  1206.     else
  1207.     {
  1208.       struct Entry *next = (struct Entry *)enode->link.mln_Succ;
  1209.       if(next->link.mln_Succ)
  1210.       {
  1211.         if(-1 == FPrintf(tfh,"<link rel=\"next\" href=\"%s\" title=\"%s\" />\n",next->Node,textlabs.next)) break;
  1212.       }
  1213.     }
  1214.  
  1215.     if(*enode->Help)
  1216.     {
  1217.       if(-1 == FPrintf(tfh,"<link rel=\"help\" href=\"%s\" title=\"%s\" />\n",enode->Help,textlabs.help)) break;
  1218.     }
  1219.     else if(*Help)
  1220.     {
  1221.       if(-1 == FPrintf(tfh,"<link rel=\"help\" href=\"%s\" title=\"%s\" />\n",Help,textlabs.help)) break;
  1222.     }
  1223.      else
  1224.      {
  1225.       if(-1 == FPuts(tfh,"<link rel=\"help\" href=\"http://www.unsatisfactorysoftware.co.uk/guideml/help.guide/main.html\" title=\"AmigaGuide Help\" />\n")) break;
  1226.      }
  1227.  
  1228.     if(param.homeurl)
  1229.     {
  1230.       if(-1 == FPrintf(tfh,"<link rel=\"top\" href=\"%s\" title=\"%s\" />\n",param.homeurl,textlabs.home)) break;
  1231.     }
  1232.  
  1233.     if(param.findurl)
  1234.     {
  1235.       if(-1 == FPrintf(tfh,"<link rel=\"search\" href=\"%s\" title=\"%s\" />\n",param.findurl,textlabs.find)) break;
  1236.     }
  1237.  
  1238.       if(-1 == FPuts(tfh,"<link rel=\"GuideML\" href=\"http://www.unsatisfactorysoftware.co.uk/\" title=\"Unsatisfactory Software\" />\n")) break;
  1239.  
  1240.  
  1241. //    if(-1 == FPutC(tfh,'\n')) break;
  1242.     return(1);                            // ALL OK
  1243.   }
  1244.   return(0);                              // ERROR
  1245. }
  1246. //<
  1247.  
  1248. //> Convert()
  1249. /*------------------------------------------------------------*
  1250. *   Convert()       Reads guide and creates HTML files        *
  1251. *     -> fh   input file handle                               *
  1252. *     <-      Success                                         *
  1253. */
  1254. LONG Convert(BPTR fh)
  1255. {
  1256.   STRPTR buffer = AllocVec(LINELEN,MEMF_ANY);     // allocate line buffer
  1257.   char copyright[100] = "\0";
  1258.   char author[100] = "\0";
  1259.   char version[100] = "\0";
  1260.   char master[100] = "\0";
  1261.   char database[100] = "\0";
  1262.   char keywords[100] = "\0";
  1263.   char description[200] = "\0";
  1264.   STRPTR node, title, line;
  1265.   char nodename[100];
  1266.   char filename[100];
  1267.   BPTR tfh = (BPTR)NULL;
  1268.   ULONG linenr = 0;
  1269.   short firstpage = 1;
  1270.   struct Entry *enode = (struct Entry *)entries.mlh_Head;
  1271.   register UWORD donavbar = !param.nonavbar;
  1272.   LONG wrap = 0;
  1273.   long mode;
  1274.  
  1275.   if(param.wordwrap || param.smartwrap) wrap = 1;
  1276.  
  1277.   if(!buffer) return(0);
  1278.  
  1279.   if(!wb) PutStr("Converting into HTML\n");
  1280.  
  1281.    /* search for @node */
  1282.   do
  1283.   {
  1284.     linenr++;
  1285.     if(FGets(fh,buffer,LINELEN) == NULL) goto Done;
  1286.  
  1287.    if(!param.noauto)
  1288.    {
  1289.     if(Strnicmp(buffer,"@wordwrap",9)==0)
  1290.     {
  1291.     if(!wb) PutStr("@wordwrap detected!\n");
  1292.      param.wordwrap = 1;
  1293.      wrap = 1;
  1294.      }
  1295.     if(Strnicmp(buffer,"@smartwrap",10)==0)
  1296.     {
  1297.     if(!wb) PutStr("@smartwrap detected!\n");
  1298.      param.smartwrap = 1;
  1299.      wrap = 1;
  1300.      }
  1301.    }
  1302.  
  1303.    // the below would be seriously better off as subroutines...
  1304.  
  1305.      if(Strnicmp(buffer,"@(c) ",5)==0)
  1306.      {
  1307.        line = buffer+5;
  1308.       while(*line == ' ') line++;   // Skip spaces
  1309.       if(*line == '\"') line++;     // Skip quotation mark
  1310.       title = line;
  1311.       while(*line != '\n') line++;  // search EOL
  1312.       do line--; while(*line==' '); // skip trailing spaces
  1313.       if(*line == '\"') line--;     // skip trailing quotation mark
  1314.       *++line = '\0';               // terminate the line
  1315.       strcpy(copyright,title);
  1316.     }
  1317.  
  1318.      if(Strnicmp(buffer,"@author ",8)==0)
  1319.      {
  1320.        line = buffer+8;
  1321.       while(*line == ' ') line++;   // Skip spaces
  1322.       if(*line == '\"') line++;     // Skip quotation mark
  1323.       title = line;
  1324.       while(*line != '\n') line++;  // search EOL
  1325.       do line--; while(*line==' '); // skip trailing spaces
  1326.       if(*line == '\"') line--;     // skip trailing quotation mark
  1327.       *++line = '\0';               // terminate the line
  1328.       strcpy(author,title);
  1329.      }
  1330.  
  1331.      if(Strnicmp(buffer,"@$ver:",6)==0)
  1332.      {
  1333.             line = buffer+6;
  1334.       while(*line == ' ') line++;   // Skip spaces
  1335.       if(*line == '\"') line++;     // Skip quotation mark
  1336.       title = line;
  1337.       while(*line != '\n') line++;  // search EOL
  1338.       do line--; while(*line==' '); // skip trailing spaces
  1339.       if(*line == '\"') line--;     // skip trailing quotation mark
  1340.       *++line = '\0';               // terminate the line
  1341.       strcpy(version,title);
  1342.     }
  1343.  
  1344.      if(Strnicmp(buffer,"@database ",10)==0)
  1345.      {
  1346.        line = buffer+10;
  1347.       while(*line == ' ') line++;   // Skip spaces
  1348.       if(*line == '\"') line++;     // Skip quotation mark
  1349.       title = line;
  1350.       while(*line != '\n') line++;  // search EOL
  1351.       do line--; while(*line==' '); // skip trailing spaces
  1352.       if(*line == '\"') line--;     // skip trailing quotation mark
  1353.       *++line = '\0';               // terminate the line
  1354.       strcpy(database,title);
  1355.     }
  1356.  
  1357.      if(Strnicmp(buffer,"@master ",8)==0)
  1358.      {
  1359.             line = buffer+8;
  1360.       while(*line == ' ') line++;   // Skip spaces
  1361.       if(*line == '\"') line++;     // Skip quotation mark
  1362.       title = line;
  1363.       while(*line != '\n') line++;  // search EOL
  1364.       do line--; while(*line==' '); // skip trailing spaces
  1365.       if(*line == '\"') line--;     // skip trailing quotation mark
  1366.       *++line = '\0';               // terminate the line
  1367.       strcpy(master,title);
  1368.     }
  1369.  
  1370.      if(Strnicmp(buffer,"@keywords ",10)==0)
  1371.      {
  1372.             line = buffer+10;
  1373.       while(*line == ' ') line++;   // Skip spaces
  1374.       if(*line == '\"') line++;     // Skip quotation mark
  1375.       title = line;
  1376.       while(*line != '\n') line++;  // search EOL
  1377.       do line--; while(*line==' '); // skip trailing spaces
  1378.       if(*line == '\"') line--;     // skip trailing quotation mark
  1379.       *++line = '\0';               // terminate the line
  1380.      strcpy(keywords,title);
  1381.     }
  1382.  
  1383.      if(Strnicmp(buffer,"@description ",13)==0)
  1384.      {
  1385.             line = buffer+13;
  1386.       while(*line == ' ') line++;   // Skip spaces
  1387.       if(*line == '\"') line++;     // Skip quotation mark
  1388.       title = line;
  1389.       while(*line != '\n') line++;  // search EOL
  1390.       do line--; while(*line==' '); // skip trailing spaces
  1391.       if(*line == '\"') line--;     // skip trailing quotation mark
  1392.       *++line = '\0';               // terminate the line
  1393.      strcpy(description,title);
  1394.     }
  1395.  
  1396.   }
  1397.   while(Strnicmp(buffer,"@node ",strlen("@node ")));
  1398.  
  1399.    /* and go... */
  1400.   for(;;)
  1401.   {
  1402.     if(SetSignal(0L,SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) goto ErrorBrk;
  1403.  
  1404.      /* search the node name */
  1405.     node = buffer+strlen("@node ");
  1406.     while(*node == ' ') node++;     // skip leading spaces
  1407.     if(*node == '\"')
  1408.     {                               // Quote Mode
  1409.       node++;
  1410.       line = node;
  1411.       while(*line!='\"' && *line!='\n')
  1412.       {
  1413.         if(*line==' ' || *line==':') *line='_';  // space -> '_'
  1414.         line++;
  1415.       }
  1416.       *line++ = '\0';
  1417.     }
  1418.     else
  1419.     {
  1420.       line = node;
  1421.       while(*line!=' ' && *line!='\n')
  1422.       {
  1423.         if(*line==':') *line='/';               // ':' -> '_'
  1424.         line++;
  1425.       }
  1426.       *line++ = '\0';
  1427.     }
  1428.  
  1429.      /* search node title */
  1430.     if(*line == '\0' || *line == '\n')
  1431.         {
  1432.       title = line;                 // Node does not have a title
  1433.         if(*enode->Titl)
  1434.             {
  1435.                 title = enode->Titl;
  1436.  
  1437. //printf("%s\n",title);
  1438.  
  1439.             }
  1440.         }
  1441.     else
  1442.     {
  1443.       while(*line == ' ') line++;   // Skip spaces
  1444.       if(*line == '\"') line++;     // Skip quotation mark
  1445.       title = line;
  1446.       while(*line != '\n') line++;  // search EOL
  1447.       do line--; while(*line==' '); // skip trailing spaces
  1448.       if(*line == '\"') line--;     // skip trailing quotation mark
  1449.       *++line = '\0';               // terminate the line
  1450.     }
  1451.  
  1452.     strlwr(node);                   // node name to lowercase
  1453.  
  1454.     strcpy(nodename,node);
  1455.  
  1456.         if(param.msdos)
  1457.         {
  1458.               strcat(nodename,".htm");
  1459.         }
  1460.         else
  1461.         {
  1462.               strcat(nodename,".html");
  1463.         }
  1464.  
  1465.     if(param.singlefile)
  1466.     {
  1467.         if(Strnicmp(nodename,"main",4) == 0)
  1468.         {
  1469.             mode = MODE_NEWFILE;
  1470.         }
  1471.         else
  1472.         {
  1473.             mode = MODE_OLDFILE;
  1474.         }
  1475.  
  1476.         strcpy(filename,"main.html");
  1477.     }
  1478.     else
  1479.     {
  1480.         mode = MODE_NEWFILE;
  1481.  
  1482.         strcpy(filename,nodename);
  1483.     }
  1484.  
  1485.  
  1486.     if(tfh = Open(filename,mode))
  1487.     {
  1488.  
  1489.         if(param.singlefile)
  1490.         {
  1491.             Seek(tfh,0,OFFSET_END);
  1492.         }
  1493.  
  1494.  
  1495.       if(param.verbatim) printf("Creating page '%s' (Title: '%s')\n",nodename,title);
  1496.  
  1497. if(((param.singlefile & firstpage) | (!param.singlefile)) & (!param.nohtml))
  1498. //if(!param.nohtml)
  1499. {
  1500.       if(-1 == FPuts(tfh,"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\n\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n<html>\n<head>\n<title>")) goto ErrorFile;
  1501.       if(-1 == MyPuts(tfh,title)) goto ErrorFile;
  1502.       if(-1 == FPuts(tfh,"</title>\n"
  1503.                          "<meta name=\"Generator\" content=\"GuideML " VERSIONSTR " (http://www.unsatisfactorysoftware.co.uk/guideml/)\">\n"
  1504.                          "<meta http-equiv=\"Content-Type\" content=\"text/html\">\n")) goto ErrorFile;
  1505.         // start custom meta
  1506.         if(strlen(copyright) > 2)
  1507.         {
  1508.         if(-1 == FPuts(tfh,"<meta name=\"Copyright\" content=\"")) goto ErrorFile;
  1509.         if(-1 == MyPuts(tfh,copyright)) goto ErrorFile;
  1510.         if(-1 == FPuts(tfh,"\">\n")) goto ErrorFile;
  1511.         }
  1512.         // end custom meta
  1513.         // start custom meta
  1514.         if(strlen(author) > 2)
  1515.         {
  1516.         if(-1 == FPuts(tfh,"<meta name=\"Author\" content=\"")) goto ErrorFile;
  1517.         if(-1 == MyPuts(tfh,author)) goto ErrorFile;
  1518.         if(-1 == FPuts(tfh,"\">\n")) goto ErrorFile;
  1519.         }
  1520.         // end custom meta
  1521.         // start custom meta
  1522.         if(strlen(version) > 2)
  1523.         {
  1524.         if(-1 == FPuts(tfh,"<meta name=\"Version\" content=\"")) goto ErrorFile;
  1525.         if(-1 == MyPuts(tfh,version)) goto ErrorFile;
  1526.         if(-1 == FPuts(tfh,"\">\n")) goto ErrorFile;
  1527.         }
  1528.         // end custom meta
  1529.         // start custom meta
  1530.         if(strlen(database) > 2)
  1531.         {
  1532.         if(-1 == FPuts(tfh,"<meta name=\"Database\" content=\"")) goto ErrorFile;
  1533.         if(-1 == MyPuts(tfh,database)) goto ErrorFile;
  1534.         if(-1 == FPuts(tfh,"\">\n")) goto ErrorFile;
  1535.         }
  1536.         // end custom meta
  1537.         // start custom meta
  1538.         if(strlen(master) > 2)
  1539.         {
  1540.         if(-1 == FPuts(tfh,"<meta name=\"Master\" content=\"")) goto ErrorFile;
  1541.         if(-1 == MyPuts(tfh,master)) goto ErrorFile;
  1542.         if(-1 == FPuts(tfh,"\">\n")) goto ErrorFile;
  1543.         }
  1544.         // end custom meta
  1545.         // start custom meta
  1546.         if(strlen(keywords) > 2)
  1547.         {
  1548.             if(-1 == FPuts(tfh,"<meta name=\"Keywords\" content=\"")) goto ErrorFile;
  1549.             if(-1 == MyPuts(tfh,keywords)) goto ErrorFile;
  1550.             if(-1 == FPuts(tfh,"\">\n")) goto ErrorFile;
  1551.         }
  1552.         // end custom meta
  1553.         // start custom meta
  1554.         if(strlen(description) > 2)
  1555.         {
  1556.             if(-1 == FPuts(tfh,"<meta name=\"Description\" content=\"")) goto ErrorFile;
  1557.             if(-1 == MyPuts(tfh,description)) goto ErrorFile;
  1558.             if(-1 == FPuts(tfh,"\">\n")) goto ErrorFile;
  1559.         }
  1560.         // end custom meta
  1561.  
  1562.         if(param.cssurl)
  1563.         {
  1564.             if(-1 == FPuts(tfh,"<link rel=\"stylesheet\" href=\"")) goto ErrorFile;
  1565.             if(-1 == MyPuts(tfh,param.cssurl)) goto ErrorFile;
  1566.             if(-1 == FPuts(tfh,"\" type=\"text/css\">")) goto ErrorFile;
  1567.         }
  1568.  
  1569.         if(!param.nomoznav)
  1570.         {
  1571.       if(!MozNavBar(tfh,enode)) goto ErrorFile;
  1572.       }
  1573.  
  1574.  
  1575.         if(-1 == FPuts(tfh,"</head>\n<body")) goto ErrorFile;
  1576.  
  1577.       if(param.bodyext)
  1578.       {
  1579.         if(-1 == FPutC(tfh,' ')) goto ErrorFile;
  1580.         if(-1 == MyPuts(tfh,param.bodyext)) goto ErrorFile;
  1581.       }
  1582.       if(-1 == FPuts(tfh,">\n")) goto ErrorFile;
  1583.  
  1584. }
  1585.  
  1586.         if(param.singlefile)
  1587.         {
  1588.             if(-1 == FPuts(tfh,"<a name=\"")) goto ErrorFile;
  1589.             if(-1 == MyPuts(tfh,nodename)) goto ErrorFile;
  1590.             if(-1 == FPuts(tfh,"\">")) goto ErrorFile;
  1591.               if(-1 == MyPuts(tfh,title)) goto ErrorFile;
  1592.             if(-1 == FPuts(tfh,"</a><p>")) goto ErrorFile;
  1593.             firstpage=0;
  1594.  
  1595.         }
  1596.  
  1597.       if(param.htmltoptxt)
  1598.       {
  1599.         if(-1 == FPutC(tfh,' ')) goto ErrorFile;
  1600.         if(-1 == MyPuts(tfh,param.htmltoptxt)) goto ErrorFile;
  1601.       }
  1602.       if(param.htmlheadf)
  1603.       {
  1604.         if(-1 == FPutC(tfh,' ')) goto ErrorFile;
  1605.         if(-1 == MyPuts(tfh,(STRPTR)htmltop)) goto ErrorFile;
  1606.       }
  1607.  
  1608.         if(donavbar)
  1609.         {
  1610.       if(!NavBar(tfh,enode)) goto ErrorFile;
  1611.       if(-1 == FPuts(tfh,"<hr>\n")) goto ErrorFile;
  1612.       }
  1613.  
  1614.         if(!wrap)
  1615.         {
  1616.           if(-1 == FPuts(tfh,"<pre>\n")) goto ErrorFile;
  1617.         }
  1618.         else
  1619.         {
  1620.             if(!param.varwidth)
  1621.           {
  1622.               if(-1 == FPuts(tfh,"<tt>\n")) goto ErrorFile;
  1623.           }
  1624.         }
  1625.  
  1626.       for(;;)
  1627.       {
  1628.         linenr++;
  1629.         if(FGets(fh,buffer,LINELEN) == NULL) goto ErrorEOF;
  1630.  
  1631. // TEMPORARY FOR TEST PORPOISES!
  1632. //printf("%s\n",buffer);
  1633.  
  1634.         if(buffer[0]=='@' && buffer[1]!='{')    // is it an AmigaGuide command
  1635.         {
  1636.           if(!Strnicmp(buffer,"@node ",strlen("@node "))) break;
  1637.           if(!Strnicmp(buffer,"@endnode",strlen("@endnode"))) break;
  1638.           continue;                           // unknown command
  1639.         }
  1640.  
  1641.         if(!ConvLine(tfh,buffer,linenr))
  1642.         {
  1643.             sprintf(temp,"Line %ld: Couldn't convert!\n",linenr);
  1644.           err(temp,"OK",0);
  1645.           goto Error;
  1646.         }
  1647.                 if(param.wordwrap)
  1648.                 {
  1649.                       if(-1 == FPuts(tfh,"<br>")) return(0);
  1650.                 }
  1651.  
  1652.       }
  1653.  
  1654.         if(!wrap)
  1655.         {
  1656.           if(-1 == FPuts(tfh,"</pre>\n")) goto ErrorFile;
  1657.         }
  1658.         else
  1659.         {
  1660.             if(!param.varwidth)
  1661.           {
  1662.               if(-1 == FPuts(tfh,"</tt>\n")) goto ErrorFile;
  1663.             }
  1664.         }
  1665.  
  1666.  
  1667.     if(param.singlefile)
  1668.     {
  1669.         if(-1 == FPuts(tfh,"<hr>\n")) goto ErrorFile;
  1670.     }
  1671.     else
  1672.     {
  1673.  
  1674.       if(param.footer)
  1675.       {
  1676.         if(-1 == FPuts(tfh,"<hr>\n")) goto ErrorFile;
  1677.         if(donavbar)
  1678.             {
  1679.             if(!NavBar(tfh,enode)) goto ErrorFile;
  1680.             }
  1681.       }
  1682.  
  1683.       if(param.htmlbottxt)
  1684.       {
  1685.         if(-1 == FPutC(tfh,' ')) goto ErrorFile;
  1686.         if(-1 == MyPuts(tfh,param.htmlbottxt)) goto ErrorFile;
  1687.       }
  1688.       else if(param.htmlfootf)
  1689.       {
  1690.         if(-1 == FPutC(tfh,' ')) goto ErrorFile;
  1691.         if(-1 == MyPuts(tfh,(STRPTR)htmlbot)) goto ErrorFile;
  1692.       }
  1693.         else
  1694.         {
  1695.           if(firstpage)
  1696.           {
  1697.             firstpage=0;
  1698.             if(-1 == FPuts(tfh,"<hr>\n<address>Converted using <a href=\"http://www.unsatisfactorysoftware.co.uk/guideml/\">GuideML "VERSIONSTR "</a></address>\n")) goto ErrorFile;
  1699.           }
  1700.       }
  1701.  
  1702.     if(!param.nohtml)
  1703.     {
  1704.       if(-1 == FPuts(tfh,"</body>\n</html>\n")) goto ErrorFile;
  1705.     }
  1706. }
  1707.  
  1708.       enode = (struct Entry *)enode->link.mln_Succ;
  1709.       Close(tfh);
  1710.       tfh = (BPTR)NULL;
  1711.     }
  1712.     else
  1713.     {
  1714. sprintf(temp,"Line %ld: Couldn't open %s for writing!\n",linenr,nodename);
  1715.       err(temp,"OK",0);
  1716.       goto Error;
  1717.     }
  1718.  
  1719.     while(Strnicmp(buffer,"@node ",strlen("@node ")))
  1720.     {
  1721.       linenr++;
  1722.       if(FGets(fh,buffer,LINELEN) == NULL) goto Done;
  1723.     }
  1724.   }
  1725.  
  1726. Done:
  1727.  
  1728.     if(param.singlefile)
  1729.     {
  1730.  
  1731.     if(tfh = Open(filename,MODE_OLDFILE))
  1732.     {
  1733.         Seek(tfh,0,OFFSET_END);
  1734.  
  1735.       if(param.footer)
  1736.       {
  1737.         if(donavbar)
  1738.             {
  1739.             if(!NavBar(tfh,enode)) goto ErrorFile;
  1740.             }
  1741.       }
  1742.  
  1743.       if(param.htmlbottxt)
  1744.       {
  1745.         if(-1 == FPutC(tfh,' ')) goto ErrorFile;
  1746.         if(-1 == MyPuts(tfh,param.htmlbottxt)) goto ErrorFile;
  1747.       }
  1748.       else if(param.htmlfootf)
  1749.       {
  1750.         if(-1 == FPutC(tfh,' ')) goto ErrorFile;
  1751.         if(-1 == MyPuts(tfh,(STRPTR)htmlbot)) goto ErrorFile;
  1752.       }
  1753.         else
  1754.         {
  1755.             if(-1 == FPuts(tfh,"<address>Converted using <a href=\"http://www.unsatisfactorysoftware.co.uk/guideml/\">GuideML "VERSIONSTR "</a></address>\n")) goto ErrorFile;
  1756.       }
  1757.  
  1758. if(!param.nohtml)
  1759.     {
  1760.       if(-1 == FPuts(tfh,"</body>\n</html>\n")) goto ErrorFile;
  1761.     }
  1762.  
  1763.       Close(tfh);
  1764.       tfh = (BPTR)NULL;
  1765.  
  1766.     }
  1767. }
  1768.  
  1769.  
  1770.   FreeVec(buffer);
  1771.   return(1);
  1772.  
  1773. ErrorBrk:
  1774. sprintf(temp,"Line %ld: <CTRL-C> pressed!\n",linenr);
  1775.   err(temp,"OK",0);
  1776.   goto Error;
  1777. ErrorFile:
  1778. sprintf(temp,"Line %ld: Error writing file!\n",linenr);
  1779.   err(temp,"OK",0);
  1780.   goto Error;
  1781. ErrorEOF:
  1782. sprintf(temp,"Line %ld: Unexpected EOF!\n",linenr);
  1783.   err(temp,"OK",0);
  1784. Error:
  1785.   if(tfh) Close(tfh);
  1786.   FreeVec(buffer);
  1787.   return(0);
  1788. }
  1789. //<
  1790. //> PreScan()
  1791. /*------------------------------------------------------------*
  1792. *   PreScan()       Scans the AmigaGuide file                 *
  1793. *     -> fh   input file handle                               *
  1794. *     <-      Success                                         *
  1795. */
  1796. LONG PreScan(BPTR fh)
  1797. {
  1798.   STRPTR buffer = AllocVec(LINELEN,MEMF_ANY);     // allocate line buffer
  1799.   STRPTR parse;
  1800.   STRPTR title;
  1801.   ULONG linenr  = 0;
  1802.   ULONG nodectr = 0;
  1803.   struct Entry *currentry = NULL;
  1804.  
  1805.   if(!buffer) return(0);
  1806.  
  1807.   if(!wb) PutStr("Scanning AmigaGuide document\n");
  1808.    /* Is it an AmigaGuide document ? */
  1809.   linenr++;
  1810.   if(NULL == FGets(fh,buffer,LINELEN)) goto ErrorEOF;
  1811.   if(Strnicmp(buffer,"@database",strlen("@database")))
  1812.   {
  1813.     err("This is not a valid AmigaGuide file!","OK",0);
  1814.     goto Error;
  1815.   }
  1816.  
  1817.    /* Search for commands */
  1818.   for(;;)
  1819.   {
  1820.     if(SetSignal(0L,SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) goto ErrorBrk;
  1821.     linenr++;
  1822.     if(!FGets(fh,buffer,LINELEN)) break;      // Scan all lines
  1823.     if(buffer[0]!='@') continue;              // no command line
  1824.     if(buffer[1]=='{') continue;              // a text command at first column?
  1825.  
  1826.     parse = buffer+1;
  1827.  
  1828.     if(!Strnicmp(parse,"node ",strlen("node ")))      // @node <name>
  1829.     {
  1830.       if(currentry) AddTail((struct List *)&entries,(struct Node *)currentry);
  1831.       currentry = AllocVec(sizeof(struct Entry),MEMF_ANY|MEMF_CLEAR);
  1832.       if(!currentry) goto ErrorMem;
  1833.       currentry->Count = nodectr++;
  1834.       CopyLink(parse+strlen("node "), currentry->Node);
  1835.     }
  1836.  
  1837.     if(!Strnicmp(parse,"index ",strlen("index ")))    // @index <index>
  1838.     {
  1839.       if(currentry)
  1840.       {
  1841.         CopyLink(parse+strlen("prev "), currentry->Index);
  1842.       }
  1843.       else
  1844.       {
  1845.           CopyLink(parse+strlen("index "), Index);
  1846.       }
  1847.     }
  1848.  
  1849.     if(!Strnicmp(parse,"prev ",strlen("prev ")))      // @prev <name>
  1850.     {
  1851.       if(currentry)
  1852.       {
  1853.         CopyLink(parse+strlen("prev "), currentry->Prev);
  1854.       }
  1855.     }
  1856.  
  1857.     if(!Strnicmp(parse,"next ",strlen("next ")))      // @next <name>
  1858.     {
  1859.       if(currentry)
  1860.       {
  1861.         CopyLink(parse+strlen("next "), currentry->Next);
  1862.       }
  1863.     }
  1864.  
  1865.     if(!Strnicmp(parse,"toc ",strlen("toc ")))        // @toc <name>
  1866.     {
  1867.       if(currentry)
  1868.       {
  1869.         CopyLink(parse+strlen("toc "), currentry->TOC);
  1870.       }
  1871.     }
  1872.  
  1873.     if(!Strnicmp(parse,"title ",strlen("title ")))        // @title <name>
  1874.     {
  1875.       if(currentry)
  1876.       {
  1877.       parse = parse+strlen("title ");
  1878.       while(*parse == ' ') parse++;   // Skip spaces
  1879.       if(*parse == '\"') parse++;     // Skip quotation mark
  1880.       title=parse;
  1881.       while(*parse != '\n') parse++;  // search EOL
  1882.       do parse--; while(*parse==' '); // skip trailing spaces
  1883.       if(*parse == '\"') parse--;     // skip trailing quotation mark
  1884.       *++parse = '\0';               // terminate the line
  1885.       strcpy(currentry->Titl,title);
  1886.  
  1887.         //CopyLink(parse+strlen("title "), currentry->Titl);
  1888.         }
  1889.     }
  1890.  
  1891.     if(!Strnicmp(parse,"help ",strlen("help ")))        // @help <name>
  1892.     {
  1893.       if(currentry)
  1894.       {
  1895.         CopyLink(parse+strlen("help "), currentry->Help);
  1896.       }
  1897.       else
  1898.       {
  1899.           CopyLink(parse+strlen("help "), Help);
  1900.       }
  1901.     }
  1902.  
  1903.     if(!Strnicmp(parse,"endnode",strlen("endnode")))  // @endnode
  1904.     {
  1905.       if(currentry)
  1906.       {
  1907.         AddTail((struct List *)&entries,(struct Node *)currentry);
  1908.         currentry = NULL;
  1909.       }
  1910.     }
  1911.   }
  1912.   if(currentry)
  1913.   {
  1914.     AddTail((struct List *)&entries,(struct Node *)currentry);
  1915.     if(!param.nowarn) printf("Line %ld: WARNING: No closing @endnode found!\n",linenr);
  1916. //*    currentry = NULL;
  1917.   }
  1918.  
  1919.   FreeVec(buffer);
  1920.   return(1);
  1921.  
  1922. ErrorMem:
  1923. sprintf(temp,"Line %ld: Not enough memory!\n",linenr);
  1924.   err(temp,"OK",0);
  1925.   goto Error;
  1926. ErrorBrk:
  1927. sprintf(temp,"Line %ld: <CTRL-C> pressed!\n",linenr);
  1928.   err(temp,"OK",0);
  1929.   goto Error;
  1930. ErrorEOF:
  1931. sprintf(temp,"Line %ld: Unexpected EOF!\n",linenr);
  1932.   err(temp,"OK",0);
  1933. Error:
  1934.   FreeVec(buffer);
  1935.   return(0);
  1936. }
  1937. //<
  1938.  
  1939. //> main()
  1940. /*------------------------------------------------------------*
  1941. *   main()          M A I N   P R O G R A M                   *
  1942. */
  1943. int main(int argc, char **argv)
  1944. {
  1945.  
  1946.   struct RDArgs *args;
  1947.   static char template[] = "FILE/A,TO/K,URL=HOMEURL/K,FINDURL=SEARCHURL/K,PREV/K,NEXT/K,INDEX/K,TOC/K,HELP/K,RETRACE/K,HOME/K,FIND=SEARCH/K,BAR/K,BODY/K,VER=VERBATIM/S,IMG=IMAGES/S,FTR=FOOTER/S,LA=LINKADD/K,NL=NOLINKS/S,NE=NOEMAIL/S,NW=NOWARN/S,MSDOS/S,SF=SINGLEFILE/S,NONAVBAR/S,NOMOZNAV/S,SHOWALL/S,HTMLHEAD/K,HTMLHEADF/K,HTMLFOOT/K,HTMLFOOTF/K,NOHTML/S,CSS/K,WORDWRAP/S,SMARTWRAP/S,VARWIDTH/S,NOAUTO/S";
  1948.   BPTR fh;
  1949.   BPTR hhf;
  1950.   BPTR oldlock = (BPTR)NULL;
  1951.   struct Entry *node, *next;
  1952.   struct LinkStr *lstr = NULL;
  1953.   struct FileInfoBlock *fib = NULL;
  1954.   long hfs = 4096;
  1955.   long hhs = 4096;
  1956. STRPTR oldlinkadd;
  1957.  
  1958.    if(0 == argc) return(wbmain((struct WBStartup *)argv));
  1959.  
  1960.  
  1961.  
  1962.   NewList((struct List *)&entries);
  1963.  
  1964.  
  1965. if(!wb)
  1966. {
  1967.   param.prev  = "< Browse";
  1968.   param.next  = "Browse >";
  1969.   param.index = "Index";
  1970.   param.toc   = "Contents";
  1971.   param.home  = "Home";
  1972.   param.help  = "Help";
  1973.   param.find  = "Search";
  1974.   param.bar   = defbar;
  1975.   param.retrace = NULL;
  1976.  
  1977.   if(args = (struct RDArgs *)ReadArgs(template,(LONG *)¶m,NULL))
  1978.     {
  1979.         ok=1;
  1980.     }
  1981. }
  1982.  
  1983. if(ok)
  1984.   {
  1985.    if(!wb) PutStr("GuideML "VERSIONSTR"\n");
  1986.  
  1987.   textlabs.prev = param.prev;
  1988.   textlabs.next = param.next;
  1989.   textlabs.index = param.index;
  1990.   textlabs.toc = param.toc;
  1991.   textlabs.home = param.home;
  1992.   textlabs.help = param.help;
  1993.   textlabs.find = param.find;
  1994.   textlabs.retrace = param.retrace;
  1995.   textlabs.bar = param.bar;
  1996.  
  1997.     if(param.images)
  1998.     {
  1999.       lstr = AllocVec(sizeof(struct LinkStr),MEMF_ANY);
  2000.       if(!lstr)
  2001.       {
  2002.         err("**ERROR: Out of memory.","OK",0);
  2003.         goto Flush;
  2004.       }
  2005.  
  2006.       sprintf(lstr->Prev ,"<img src=\"prev.gif\" alt=\"%s\" border=0>" ,param.prev );
  2007.       sprintf(lstr->Next ,"<img src=\"next.gif\" alt=\"%s\" border=0>" ,param.next );
  2008.       sprintf(lstr->Index,"<img src=\"index.gif\" alt=\"%s\" border=0>",param.index);
  2009.       sprintf(lstr->Retrace,"<img src=\"retrace.gif\" alt=\"%s\" border=0>",param.retrace);
  2010.       sprintf(lstr->Toc  ,"<img src=\"toc.gif\" alt=\"%s\" border=0>"  ,param.toc  );
  2011.       sprintf(lstr->Home ,"<img src=\"home.gif\" alt=\"%s\" border=0>" ,param.home );
  2012.       sprintf(lstr->Help ,"<img src=\"help.gif\" alt=\"%s\" border=0>" ,param.help );
  2013.       sprintf(lstr->Find ,"<img src=\"find.gif\" alt=\"%s\" border=0>" ,param.find );
  2014.       param.prev  = lstr->Prev;
  2015.       param.next  = lstr->Next;
  2016.       param.index = lstr->Index;
  2017.       param.toc   = lstr->Toc;
  2018.       param.home  = lstr->Home;
  2019.       param.help  = lstr->Help;
  2020.       param.find  = lstr->Find;
  2021.       if(param.retrace) param.retrace  = lstr->Retrace;
  2022.       if(param.bar == defbar) param.bar = "";
  2023.     }
  2024.  
  2025.     if(param.singlefile)
  2026.     {
  2027.         oldlinkadd = param.linkadd;
  2028.         param.linkadd = "#";
  2029.     }
  2030.  
  2031.     if(param.htmlheadf)
  2032.     {
  2033.         if(hhf=Open(param.htmlheadf,MODE_OLDFILE))
  2034.         {
  2035. //        if(ExamineFH(hhf,fib))
  2036. //            {
  2037. //                hhs=fib->fib_Size;
  2038.                 if(htmltop = AllocMem(hhs,MEMF_CLEAR))
  2039.                     {
  2040.                         Read(hhf,htmltop,hhs);
  2041.  
  2042.                         param.htmltoptxt=NULL;
  2043.                         if(!wb) printf("%s loaded ok\n",param.htmlheadf);
  2044.  
  2045.                     }
  2046.             Close(hhf);
  2047.         }
  2048.     }
  2049.  
  2050.     if(param.htmlfootf)
  2051.     {
  2052.         if(hhf=Open(param.htmlfootf,MODE_OLDFILE))
  2053.         {
  2054.                 if(htmlbot = AllocMem(hfs,MEMF_CLEAR))
  2055.                     {
  2056.                         Read(hhf,htmlbot,hfs);
  2057.                         param.htmlbottxt=NULL;
  2058.                         if(!wb) printf("%s loaded ok\n",param.htmlfootf);
  2059.                     }
  2060.             Close(hhf);
  2061.         }
  2062.     }
  2063.  
  2064.     if(fh = Open(param.from,MODE_OLDFILE))
  2065.     {
  2066.       if(param.to)
  2067.       {
  2068.         BPTR destlock;
  2069.         destlock = Lock(param.to,ACCESS_READ);
  2070.         if(!destlock)
  2071.         {
  2072.           err("**ERROR: Couldn't lock destination drawer.","OK",0);
  2073.           Close(fh);
  2074.           goto Flush;
  2075.         }
  2076.         oldlock = CurrentDir(destlock);
  2077.       }
  2078.  
  2079.       if(!PreScan(fh))
  2080.       {
  2081.         err("**ERROR: Scanning failed.","OK",0);
  2082.         Close(fh);
  2083.         goto Flush;
  2084.       }
  2085.       Seek(fh,0,OFFSET_BEGINNING);
  2086.       if(!Convert(fh))
  2087.       {
  2088.         err("**ERROR: Conversion failed.","OK",0);
  2089.         Close(fh);
  2090.         goto Flush;
  2091.       }
  2092.       Close(fh);
  2093.     }
  2094.     else
  2095.     {
  2096. sprintf(temp,"**ERROR: couldn't open file %s!\n",param.from);
  2097.       err(temp,"OK",0);
  2098.     }
  2099.  
  2100.     if(param.images)
  2101.     {
  2102.       if(!wb) PutStr("Saving images\n");
  2103.       if(!SaveImages())
  2104.         err("**ERROR: couldn't save image files","OK",0);
  2105.     }
  2106.  
  2107.     if(!wb) printf("All finished!\n");
  2108.  
  2109.     if(param.singlefile)
  2110.     {
  2111.         param.linkadd = oldlinkadd;
  2112.     }
  2113.  
  2114.  
  2115. Flush:
  2116.     for (node = (struct Entry *)entries.mlh_Head;
  2117.          next = (struct Entry *)node->link.mln_Succ;
  2118.          node = next)
  2119.     {
  2120.       Remove((struct Node *)node);
  2121.       FreeVec(node);
  2122.     }
  2123.  
  2124.     if(lstr) FreeVec(lstr);
  2125.     if(htmltop) FreeMem(htmltop,hhs);
  2126.     if(htmlbot) FreeMem(htmlbot,hfs);
  2127.  
  2128.  
  2129.     if(oldlock) UnLock(CurrentDir(oldlock));
  2130.  
  2131.     if(!wb) FreeArgs(args);
  2132.   }
  2133.   else
  2134.     PutStr("GuideML "VERSIONSTR"\n"
  2135.            "© 1997-98 by Richard Körber <shred@eratosthenes.starfleet.de>\n"
  2136.            "Updated in 2001-04 by Chris Young <chris@unsatisfactorysoftware.co.uk>\n"
  2137.            "Yet Another (tm) AmigaGuide to HTML Converter!\n\n"
  2138.            "USAGE:\tFILE/A\t\t\tAmigaGuide file to be converted\n"
  2139.            "\tTO/K\t\t\tDestination drawer for the html pages\n"
  2140.            "\tURL=HOMEURL/K\t\tURL accessed by the 'HOME' button\n"
  2141.            "\tFINDURL=SEARCHURL/K\tURL accessed by the 'SEARCH' button\n"
  2142.            "\tPREV/K\t\t\t'PREV' button text/image\n"
  2143.            "\tNEXT/K\t\t\t'NEXT' button text/image\n"
  2144.            "\tINDEX/K\t\t\t'INDEX' button text/image\n"
  2145.            "\tTOC/K\t\t\t'CONTENTS' button text/image\n"
  2146.            "\tHELP/K\t\t\t'HELP' button text/image\n"
  2147.            "\tRETRACE/K\t\t'RETRACE' button text/image (displays only if specified)\n"
  2148.            "\tHOME/K\t\t\t'HOME' button text/image\n"
  2149.            "\tFIND=SEARCH/K\t\t'SEARCH' button text/image\n"
  2150.            "\tBAR/K\t\t\tBar text between navigation buttons\n"
  2151.            "\tBODY/K\t\t\tAddition to the body tag of every page\n"
  2152.            "\tVER=VERBATIM/S\t\tList of created files\n"
  2153.            "\tIMG=IMAGES/S\t\tCreate image navigation bar\n"
  2154.            "\tFTR=FOOTER/S\t\tNavigation bar also at end of page\n"
  2155.            "\tLA=LINKADD/K\t\tText to add to the start of each page URLs\n"
  2156.            "\tNL=NOLINKS/S\t\tIgnore internet links\n"
  2157.            "\tNE=NOEMAIL/S\t\tIgnore e-mail addresses\n"
  2158.            "\tNW=NOWARN/S\t\tDon't show warnings\n"
  2159.            "\tMSDOS/S\t\t\tCreate MS-DOS filenames (*.htm)\n"
  2160.            "\tSF=SINGLEFILE/S\t\tPut all nodes into a single HTML file\n"
  2161.            "\tNONAVBAR/S\t\tDo not create the HTML navigation bar\n"
  2162.            "\tNOMOZNAV/S\t\tDo not create Mozilla-compatible Site Navigation Bar\n"
  2163.            "\tSHOWALL/S\t\tKeep navbar consistent between pages\n"
  2164.            "\tHTMLHEAD/K\t\tHTML to put in front of guide text\n"
  2165.            "\tHTMLHEADF/K\t\tFile containing HTMLHEAD (overrides HTMLHEAD)\n"
  2166.            "\tHTMLFOOT/K\t\tHTML to put underneath guide text\n"
  2167.            "\tHTMLFOOTF/K\t\tFile containing HTMLFOOT (overrides HTMLFOOT)\n"
  2168.            "\tNOHTML/K\t\tDo not auto-generate HTML headers or footers\n"
  2169.            "\tCSS/K\t\t\tURL of Cascading Style Sheet to link to\n"
  2170.            "\tWORDWRAP/S\t\tWord-wraps text (converts @wordwrap)\n"
  2171.            "\tSMARTWRAP/S\t\tSmartwraps text (converts @smartwrap)\n"
  2172.            "\tVARWIDTH/S\t\tDo not use fixed width font (#?WRAP only)\n"
  2173.            "\tNOAUTO/S\t\tDo not auto-detect wrap mode\n"
  2174.  
  2175.            "\n");
  2176.   return(0);
  2177. }
  2178. //<
  2179.  
  2180. /**************************************************************/
  2181.  
  2182. /* New GuiML stuff starts here.. code might be a bit messy *
  2183.  * as it is largely cut'n'paste from a different project   *
  2184.  * --- Starts with GuideML 3.1 ---                         */
  2185.  
  2186. int wbmain(struct WBStartup *WBenchMsg)
  2187. {
  2188. struct WBArg *wbarg;
  2189.     char i;
  2190.     int olddir;
  2191. int name = 0;
  2192.  
  2193. wb=1;
  2194. ok=1;
  2195.  
  2196.   param.prev  = "< Browse";
  2197.   param.next  = "Browse >";
  2198.   param.index = "Index";
  2199.   param.toc   = "Contents";
  2200.   param.home  = "Home";
  2201.   param.help  = "Help";
  2202.   param.find  = "Search";
  2203.   param.bar   = defbar;
  2204.   param.retrace = NULL;
  2205.  
  2206. param.nowarn = TRUE;
  2207.  
  2208. #ifndef __amigaos4__
  2209.  
  2210.     if((intuitionbase = OpenLibrary("intuition.library",37))==0)
  2211.         {
  2212.           err("Unable to open intuition.library v37","OK",20);
  2213.         }
  2214.  
  2215.     if((dosbase = OpenLibrary("dos.library",37))==0)
  2216.         {
  2217.           err("Unable to open dos.library v37","OK",20);
  2218.         }
  2219.  
  2220.     if((aslbase = OpenLibrary("asl.library",38))==0)
  2221.         {
  2222.           err("Unable to open asl.library v38","OK",20);
  2223.         }
  2224.     if((GadToolsBase = OpenLibrary("gadtools.library",37))==0)
  2225.         {
  2226.           err("Unable to open gadtools.library v37","OK",20);
  2227.         }
  2228.  
  2229.      if((WindowBase = OpenLibrary("window.class",44))==0) err("Unable to open window.class v44","OK",20);
  2230.      if((LayoutBase = OpenLibrary("gadgets/layout.gadget",44))==0) err("Unable to open layout.gadget v44","OK",20);
  2231.      if((ButtonBase = OpenLibrary("gadgets/button.gadget",44))==0) err("Unable to open button.gadget v44","OK",20);
  2232.      if((CheckBoxBase = OpenLibrary("gadgets/checkbox.gadget",44))==0) err("Unable to open checkbox.gadget v44","OK",20);
  2233.      if((LabelBase = OpenLibrary("images/label.image",44))==0) err("Unable to open label.image v44","OK",20);
  2234.      if((ChooserBase = OpenLibrary("gadgets/chooser.gadget",44))==0) err("Unable to open chooser.gadget v44","OK",20);
  2235.      if((ClickTabBase = OpenLibrary("gadgets/clicktab.gadget",44))==0) err("Unable to open clicktab.gadget v44","OK",20);
  2236. //     if((IntegerBase = OpenLibrary("gadgets/integer.gadget",44))==0) err("Unable to open integer.gadget v44","OK",20);
  2237. //     if((ListBrowserBase = OpenLibrary("gadgets/listbrowser.gadget",44))==0) err("Unable to open listbrowser.gadget v44","OK",20);
  2238.      if((GetFileBase = OpenLibrary("gadgets/getfile.gadget",44))==0) err("Unable to open getfile.gadget v44","OK",20);
  2239.      if((StringBase = OpenLibrary("gadgets/string.gadget",44))==0) err("Unable to open string.gadget v44","OK",20);
  2240.  
  2241.  
  2242.     IconBase = OpenLibrary("icon.library",44);
  2243.     if(!IconBase) err("Cannot open icon.library v44","OK",20);
  2244. #endif
  2245.  
  2246.  
  2247.     if((GadToolsBase = OpenLibrary("gadtools.library",37))==0)
  2248.         {
  2249.          err("Unable to open gadtools.library v37","OK",20);
  2250.         }
  2251.  
  2252.     if((UtilityBase = OpenLibrary("utility.library",37))==0)
  2253.         {
  2254.          err("Unable to open utility.library v37","OK",20);
  2255.         }
  2256.  
  2257. #ifdef __amigaos4__
  2258.  
  2259.     IGadTools=(struct GadToolsIFace *)GetInterface(GadToolsBase,"main",1,NULL);
  2260.         IUtility=(struct UtilityIFace *)GetInterface(UtilityBase,"main",1,NULL);
  2261.  
  2262. #endif
  2263.  
  2264.  
  2265.  
  2266.     for(i=0,wbarg=WBenchMsg->sm_ArgList;i<WBenchMsg->sm_NumArgs;i++,wbarg++)
  2267.         {
  2268.         olddir =-1;
  2269.         if((wbarg->wa_Lock)&&(*wbarg->wa_Name))
  2270.             olddir = CurrentDir(wbarg->wa_Lock);
  2271. if(!name)
  2272. {
  2273. strcpy(defname,"PROGDIR:");
  2274.  AddPart(defname,wbarg->wa_Name,100);
  2275.  name=1;
  2276. }
  2277.  
  2278.         gettooltypes(wbarg);
  2279.  
  2280.         if(olddir !=-1) CurrentDir(olddir);
  2281.         }
  2282.  
  2283. ui();
  2284.  
  2285. }
  2286.  
  2287. void gettooltypes(struct WBArg *wbarg)
  2288. {
  2289.     struct DiskObject *dobj;
  2290.     CONST_STRPTR *toolarray;
  2291.     char *s;
  2292.  
  2293.  
  2294.     if((*wbarg->wa_Name) && (dobj=GetIconTags(wbarg->wa_Name,NULL)))
  2295.         {
  2296.         toolarray = (CONST_STRPTR *)dobj->do_ToolTypes;
  2297.         if(s = (char *)FindToolType(toolarray,"FILE"))
  2298.             {
  2299.                 ttfrom = AllocMem(strlen(s)+1,NULL);
  2300.                 if(ttfrom)
  2301.                     {
  2302.                          strcpy(ttfrom,s);
  2303.                          param.from = ttfrom;
  2304.                     }
  2305.             }
  2306.         if(s = (char *)FindToolType(toolarray,"TO"))
  2307.             {
  2308.                 ttto = AllocMem(strlen(s)+1,NULL);
  2309.                 if(ttto)
  2310.                     {
  2311.                          strcpy(ttto,s);
  2312.                          param.to = ttto;
  2313.                     }
  2314.             }
  2315.  
  2316.         if(s = (char *)FindToolType(toolarray,"HOMEURL"))
  2317.             {
  2318.                 tthomeurl = AllocMem(strlen(s)+1,NULL);
  2319.                 if(tthomeurl)
  2320.                     {
  2321.                          strcpy(tthomeurl,s);
  2322.                          param.homeurl = tthomeurl;
  2323.                     }
  2324.             }
  2325.  
  2326.         if(s = (char *)FindToolType(toolarray,"SEARCHURL"))
  2327.             {
  2328.                 ttfindurl = AllocMem(strlen(s)+1,NULL);
  2329.                 if(ttfindurl)
  2330.                     {
  2331.                          strcpy(ttfindurl,s);
  2332.                          param.findurl = ttfindurl;
  2333.                     }
  2334.             }
  2335.  
  2336.         if(s = (char *)FindToolType(toolarray,"PREV"))
  2337.             {
  2338.                 ttprev = AllocMem(strlen(s)+1,NULL);
  2339.                 if(ttprev)
  2340.                     {
  2341.                          strcpy(ttprev,s);
  2342.                          param.prev = ttprev;
  2343.                     }
  2344.             }
  2345.  
  2346.         if(s = (char *)FindToolType(toolarray,"NEXT"))
  2347.             {
  2348.                 ttnext = AllocMem(strlen(s)+1,NULL);
  2349.                 if(ttnext)
  2350.                     {
  2351.                          strcpy(ttnext,s);
  2352.                          param.next = ttnext;
  2353.                     }
  2354.             }
  2355.  
  2356.         if(s = (char *)FindToolType(toolarray,"INDEX"))
  2357.             {
  2358.                 ttindex = AllocMem(strlen(s)+1,NULL);
  2359.                 if(ttindex)
  2360.                     {
  2361.                          strcpy(ttindex,s);
  2362.                          param.index = ttindex;
  2363.                     }
  2364.             }
  2365.  
  2366.         if(s = (char *)FindToolType(toolarray,"TOC"))
  2367.             {
  2368.                 tttoc = AllocMem(strlen(s)+1,NULL);
  2369.                 if(tttoc)
  2370.                     {
  2371.                          strcpy(tttoc,s);
  2372.                          param.toc = tttoc;
  2373.                     }
  2374.             }
  2375.  
  2376.         if(s = (char *)FindToolType(toolarray,"HELP"))
  2377.             {
  2378.                 tthelp = AllocMem(strlen(s)+1,NULL);
  2379.                 if(tthelp)
  2380.                     {
  2381.                          strcpy(tthelp,s);
  2382.                          param.help = tthelp;
  2383.                     }
  2384.             }
  2385.  
  2386.         if(s = (char *)FindToolType(toolarray,"RETRACE"))
  2387.             {
  2388.                 ttretrace = AllocMem(strlen(s)+1,NULL);
  2389.                 if(ttretrace)
  2390.                     {
  2391.                          strcpy(ttretrace,s);
  2392.                          param.retrace = ttretrace;
  2393.                     }
  2394.             }
  2395.  
  2396.         if(s = (char *)FindToolType(toolarray,"HOME"))
  2397.             {
  2398.                 tthome = AllocMem(strlen(s)+1,NULL);
  2399.                 if(tthome)
  2400.                     {
  2401.                          strcpy(tthome,s);
  2402.                          param.home = tthome;
  2403.                     }
  2404.             }
  2405.  
  2406.         if(s = (char *)FindToolType(toolarray,"SEARCH"))
  2407.             {
  2408.                 ttfind = AllocMem(strlen(s)+1,NULL);
  2409.                 if(ttfind)
  2410.                     {
  2411.                          strcpy(ttfind,s);
  2412.                          param.find = ttfind;
  2413.                     }
  2414.             }
  2415.  
  2416.         if(s = (char *)FindToolType(toolarray,"BAR"))
  2417.             {
  2418.                 ttbar = AllocMem(strlen(s)+1,NULL);
  2419.                 if(ttbar)
  2420.                     {
  2421.                          strcpy(ttbar,s);
  2422.                          param.bar = ttbar;
  2423.                     }
  2424.             }
  2425.  
  2426.         if(s = (char *)FindToolType(toolarray,"BODY"))
  2427.             {
  2428.                 ttbody = AllocMem(strlen(s)+1,NULL);
  2429.                 if(ttbody)
  2430.                     {
  2431.                          strcpy(ttbody,s);
  2432.                          param.bodyext = ttbody;
  2433.                     }
  2434.             }
  2435.  
  2436.         if(s = (char *)FindToolType(toolarray,"HTMLHEADF"))
  2437.             {
  2438.                 tthtmlheadf = AllocMem(strlen(s)+1,NULL);
  2439.                 if(tthtmlheadf)
  2440.                     {
  2441.                          strcpy(tthtmlheadf,s);
  2442.                          param.htmlheadf = tthtmlheadf;
  2443.                     }
  2444.             }
  2445.  
  2446.         if(s = (char *)FindToolType(toolarray,"HTMLFOOTF"))
  2447.             {
  2448.                 tthtmlfootf = AllocMem(strlen(s)+1,NULL);
  2449.                 if(tthtmlfootf)
  2450.                     {
  2451.                          strcpy(tthtmlfootf,s);
  2452.                          param.htmlfootf = tthtmlfootf;
  2453.                     }
  2454.             }
  2455.  
  2456.         if(s = (char *)FindToolType(toolarray,"LINKADD"))
  2457.             {
  2458.                 ttlinkadd = AllocMem(strlen(s)+1,NULL);
  2459.                 if(ttlinkadd)
  2460.                     {
  2461.                          strcpy(ttlinkadd,s);
  2462.                          param.linkadd = ttlinkadd;
  2463.                     }
  2464.             }
  2465.  
  2466.         if(s = (char *)FindToolType(toolarray,"CSS"))
  2467.             {
  2468.                 ttcss = AllocMem(strlen(s)+1,NULL);
  2469.                 if(ttcss)
  2470.                     {
  2471.                          strcpy(ttcss,s);
  2472.                          param.cssurl = ttcss;
  2473.                     }
  2474.             }
  2475.  
  2476.         if(s = (char *)FindToolType(toolarray,"SINGLEFILE")) param.singlefile = TRUE;
  2477.         if(s = (char *)FindToolType(toolarray,"NOHTML")) param.nohtml = TRUE;
  2478.         if(s = (char *)FindToolType(toolarray,"IMAGES")) param.images = TRUE;
  2479.         if(s = (char *)FindToolType(toolarray,"FOOTER")) param.footer = TRUE;
  2480.         if(s = (char *)FindToolType(toolarray,"NOLINKS")) param.nolink = TRUE;
  2481.         if(s = (char *)FindToolType(toolarray,"NOEMAIL")) param.noemail = TRUE;
  2482.         if(s = (char *)FindToolType(toolarray,"MSDOS")) param.msdos = TRUE;
  2483.         if(s = (char *)FindToolType(toolarray,"NONAVBAR")) param.nonavbar = TRUE;
  2484.         if(s = (char *)FindToolType(toolarray,"NOMOZNAV")) param.nomoznav = TRUE;
  2485.         if(s = (char *)FindToolType(toolarray,"SHOWALL")) param.showall = TRUE;
  2486.         if(s = (char *)FindToolType(toolarray,"VARWIDTH")) param.varwidth = TRUE;
  2487.         if(s = (char *)FindToolType(toolarray,"NOAUTO")) param.noauto = TRUE;
  2488.         if(s = (char *)FindToolType(toolarray,"WORDWRAP")) param.wordwrap = TRUE;
  2489.         if(s = (char *)FindToolType(toolarray,"SMARTWRAP")) param.smartwrap = TRUE;
  2490.         FreeDiskObject(dobj);
  2491.         }
  2492.  
  2493. }
  2494.  
  2495. void savetooltypes(char *fname,int def)
  2496. {
  2497.     struct DiskObject *dobj;
  2498.     UBYTE **oldtooltypes;
  2499.     UBYTE *olddefaulttool;
  2500.     UBYTE oldtype;
  2501.     long olddir=-1;
  2502.     UBYTE *newtooltypes[35];
  2503.     char tttmp1[100];
  2504.     char tttmp2[100];
  2505.     char tttmp3[100];
  2506.     char tttmp4[100];
  2507.     char tttmp5[100];
  2508.     char tttmp6[100];
  2509.     char tttmp7[100];
  2510.     char tttmp8[100];
  2511.     char tttmp9[100];
  2512.     char tttmp10[100];
  2513.     char tttmp11[100];
  2514.     char tttmp12[100];
  2515.     char tttmp13[100];
  2516.     char tttmp14[100];
  2517.     char tttmp15[100];
  2518.     char tttmp16[100];
  2519.     char tttmp17[100];
  2520.     char tttmp18[100];
  2521.     char defaulttool[] = "guideml\0";
  2522.  
  2523. //char *fname="progdir:guideml\0";
  2524.  
  2525. // if((wbarg->wa_Lock) && (wbarg->wa_Name)) olddir=CurrentDir(wbarg->wa_Lock);
  2526.  
  2527. //    if((*wbarg->wa_Name) && (dobj=GetDiskObject(wbarg->wa_Name)))
  2528.     if(dobj=GetIconTags(fname,ICONGETA_FailIfUnavailable,FALSE,NULL))
  2529.         {
  2530.             oldtooltypes = dobj->do_ToolTypes;
  2531.             olddefaulttool = dobj->do_DefaultTool;
  2532.             oldtype = dobj->do_Type;
  2533.  
  2534.             if(param.smartwrap) newtooltypes[0] = "SMARTWRAP";
  2535.                                 else newtooltypes[0] = "(SMARTWRAP)";
  2536.             if(param.wordwrap) newtooltypes[1] = "WORDWRAP";
  2537.                                 else newtooltypes[1] = "(WORDWRAP)";
  2538.             if(param.noauto) newtooltypes[2] = "NOAUTO";
  2539.                                 else newtooltypes[2] = "(NOAUTO)";
  2540.             if(param.varwidth) newtooltypes[3] = "VARWIDTH";
  2541.                                 else newtooltypes[3] = "(VARWIDTH)";
  2542.             if(param.showall) newtooltypes[4] = "SHOWALL";
  2543.                                 else newtooltypes[4] = "(SHOWALL)";
  2544.             if(param.nomoznav) newtooltypes[5] = "NOMOZNAV";
  2545.                                 else newtooltypes[5] = "(NOMOZNAV)";
  2546.             if(param.nonavbar) newtooltypes[6] = "NONAVBAR";
  2547.                                 else newtooltypes[6] = "(NONAVBAR)";
  2548.             if(param.msdos) newtooltypes[7] = "MSDOS";
  2549.                                 else newtooltypes[7] = "(MSDOS)";
  2550.             if(param.noemail) newtooltypes[8] = "NOEMAIL";
  2551.                                 else newtooltypes[8] = "(NOEMAIL)";
  2552.             if(param.nolink) newtooltypes[9] = "NOLINKS";
  2553.                                 else newtooltypes[9] = "(NOLINKS)";
  2554.             if(param.footer) newtooltypes[10] = "FOOTER";
  2555.                                 else newtooltypes[10] = "(FOOTER)";
  2556.             if(param.images) newtooltypes[11] = "IMAGES";
  2557.                                 else newtooltypes[11] = "(IMAGES)";
  2558.             if(param.cssurl)
  2559.             {
  2560.                 strcpy(tttmp1,"CSS=");
  2561.                 newtooltypes[12] = strcat(tttmp1,param.cssurl);
  2562.             }
  2563.                 else
  2564.             {
  2565.                 newtooltypes[12]="(CSS=)";
  2566.             }
  2567.  
  2568.             if(param.htmlfootf)
  2569.             {
  2570.                 strcpy(tttmp2,"HTMLFOOTF=");
  2571.                 newtooltypes[13] = strcat(tttmp2,param.htmlfootf);
  2572.             }
  2573.                 else
  2574.             {
  2575.                 newtooltypes[13]="(HTMLFOOTF=)";
  2576.             }
  2577.  
  2578.             if(param.htmlheadf)
  2579.             {
  2580.                 strcpy(tttmp3,"HTMLHEADF=");
  2581.                 newtooltypes[14] = strcat(tttmp3,param.htmlheadf);
  2582.             }
  2583.                 else
  2584.             {
  2585.                 newtooltypes[14]="(HTMLHEADF=)";
  2586.             }
  2587.  
  2588.             if(param.bodyext)
  2589.             {
  2590.                 strcpy(tttmp4,"BODY=");
  2591.                 newtooltypes[15] = strcat(tttmp4,param.bodyext);
  2592.             }
  2593.                 else
  2594.             {
  2595.                 newtooltypes[15]="(BODY=)";
  2596.             }
  2597.  
  2598.             if(param.bar)
  2599.             {
  2600.                 strcpy(tttmp5,"BAR=");
  2601.                 newtooltypes[16] = strcat(tttmp5,param.bar);
  2602.             }
  2603.                 else
  2604.             {
  2605.                 newtooltypes[16]="(BAR=)";
  2606.             }
  2607.  
  2608.             if(param.find)
  2609.             {
  2610.                 strcpy(tttmp6,"SEARCH=");
  2611.                 newtooltypes[17] = strcat(tttmp6,param.find);
  2612.             }
  2613.                 else
  2614.             {
  2615.                 newtooltypes[17]="(SEARCH=)";
  2616.             }
  2617.  
  2618.             if(param.home)
  2619.             {
  2620.                 strcpy(tttmp7,"HOME=");
  2621.                 newtooltypes[18] = strcat(tttmp7,param.home);
  2622.             }
  2623.                 else
  2624.             {
  2625.                 newtooltypes[18]="(HOME=)";
  2626.             }
  2627.  
  2628.             if(param.retrace)
  2629.             {
  2630.                 strcpy(tttmp8,"RETRACE=");
  2631.                 newtooltypes[19] = strcat(tttmp8,param.retrace);
  2632.             }
  2633.                 else
  2634.             {
  2635.                 newtooltypes[19]="(RETRACE=)";
  2636.             }
  2637.  
  2638.             if(param.help)
  2639.             {
  2640.                 strcpy(tttmp9,"HELP=");
  2641.                 newtooltypes[20] = strcat(tttmp9,param.help);
  2642.             }
  2643.                 else
  2644.             {
  2645.                 newtooltypes[20]="(HELP=)";
  2646.             }
  2647.  
  2648.             if(param.toc)
  2649.             {
  2650.                 strcpy(tttmp10,"TOC=");
  2651.                 newtooltypes[21] = strcat(tttmp10,param.toc);
  2652.             }
  2653.                 else
  2654.             {
  2655.                 newtooltypes[21]="(TOC=)";
  2656.             }
  2657.  
  2658.             if(param.index)
  2659.             {
  2660.                 strcpy(tttmp11,"INDEX=");
  2661.                 newtooltypes[22] = strcat(tttmp11,param.index);
  2662.             }
  2663.                 else
  2664.             {
  2665.                 newtooltypes[22]="(INDEX=)";
  2666.             }
  2667.  
  2668.             if(param.next)
  2669.             {
  2670.                 strcpy(tttmp12,"NEXT=");
  2671.                 newtooltypes[23] = strcat(tttmp12,param.next);
  2672.             }
  2673.                 else
  2674.             {
  2675.                 newtooltypes[23]="(NEXT=)";
  2676.             }
  2677.  
  2678.             if(param.prev)
  2679.             {
  2680.                 strcpy(tttmp13,"PREV=");
  2681.                 newtooltypes[24] = strcat(tttmp13,param.prev);
  2682.             }
  2683.                 else
  2684.             {
  2685.                 newtooltypes[24]="(PREV=)";
  2686.             }
  2687.  
  2688.             if(param.findurl)
  2689.             {
  2690.                 strcpy(tttmp14,"SEARCHURL=");
  2691.                 newtooltypes[25] = strcat(tttmp14,param.findurl);
  2692.             }
  2693.                 else
  2694.             {
  2695.                 newtooltypes[25]="(SEARCHURL=)";
  2696.             }
  2697.  
  2698.             if(param.homeurl)
  2699.             {
  2700.                 strcpy(tttmp15,"HOMEURL=");
  2701.                 newtooltypes[26] = strcat(tttmp15,param.homeurl);
  2702.             }
  2703.                 else
  2704.             {
  2705.                 newtooltypes[26]="(HOMEURL=)";
  2706.             }
  2707.  
  2708.             if(param.linkadd)
  2709.             {
  2710.                 strcpy(tttmp18,"LINKADD=");
  2711.                 newtooltypes[27] = strcat(tttmp18,param.linkadd);
  2712.             }
  2713.                 else
  2714.             {
  2715.                 newtooltypes[27]="(LINKADD=)";
  2716.             }
  2717.  
  2718.             if(param.nohtml) newtooltypes[28] = "NOHTML";
  2719.                                 else newtooltypes[28] = "(NOHTML)";
  2720.  
  2721.             if(param.singlefile) newtooltypes[29] = "SINGLEFILE";
  2722.                                 else newtooltypes[29] = "(SINGLEFILE)";
  2723.  
  2724.         if(!def)
  2725.         {
  2726.  
  2727.             if(param.to)
  2728.             {
  2729.                 strcpy(tttmp16,"TO=");
  2730.                 newtooltypes[30] = strcat(tttmp16,param.to);
  2731.             }
  2732.                 else
  2733.             {
  2734.                 newtooltypes[30]="(TO=)";
  2735.             }
  2736.  
  2737.             if(param.from)
  2738.             {
  2739.                 strcpy(tttmp17,"FILE=");
  2740.                 newtooltypes[31] = strcat(tttmp17,param.from);
  2741.             }
  2742.                 else
  2743.             {
  2744.                 newtooltypes[31]="(FILE=)";
  2745.             }
  2746.  
  2747.             dobj->do_DefaultTool = defaulttool;
  2748.             dobj->do_Type = WBPROJECT;
  2749.  
  2750.         }
  2751.         else
  2752.         {
  2753.             newtooltypes[30]=NULL;
  2754.         }
  2755.  
  2756.             newtooltypes[32] = NULL;
  2757.             dobj->do_ToolTypes = newtooltypes;
  2758.             PutIconTags(fname,dobj,NULL); //            PutDiskObject(fname,dobj); // PutDiskObject(wbarg->wa_Name,dobj);
  2759.             dobj->do_ToolTypes=oldtooltypes;
  2760.             dobj->do_DefaultTool=olddefaulttool;
  2761.             dobj->do_Type = oldtype;
  2762.             FreeDiskObject(dobj);
  2763.         }
  2764.  
  2765. // if(olddir!=-1) CurrentDir(olddir);
  2766.  
  2767. }
  2768.  
  2769. int saveas()
  2770. {
  2771.     BPTR fp;
  2772.     int t;
  2773.     char *filename[2048];
  2774.     char guidemlcmd[4096];
  2775.     struct FileRequester *req;
  2776.     struct TagItem asltags[] = {ASLFR_TitleText,(ULONG)"Save As...",
  2777.                              ASLFR_InitialShowVolumes,TRUE,
  2778.                              ASLFR_DoSaveMode,TRUE,TAG_DONE};
  2779.  
  2780.     req = (struct FileRequester *)AllocAslRequest(ASL_FileRequest,NULL);
  2781.     t = AslRequest(req,asltags);
  2782.  
  2783.     if (t==FALSE)
  2784.    {
  2785.         // user cancelled
  2786.         return(0);
  2787.     }
  2788.  
  2789.     strcpy((STRPTR)filename,req->fr_Drawer);
  2790.     AddPart((STRPTR)filename,req->fr_File,2048);
  2791.  
  2792.     FreeAslRequest(req);
  2793.  
  2794.     fp = Open((STRPTR)filename,MODE_NEWFILE);
  2795.  
  2796.     strcpy(guidemlcmd,"guideml \"");
  2797.     if(param.from) strcat(guidemlcmd,param.from);
  2798.     if(param.from) strcat(guidemlcmd,"\" ");
  2799.     if(param.to) strcat(guidemlcmd,"TO=\"");
  2800.     if(param.to) strcat(guidemlcmd,param.to);
  2801.     if(param.to) strcat(guidemlcmd,"\" ");
  2802.     if(param.homeurl) strcat(guidemlcmd,"HOMEURL=\"");
  2803.     if(param.homeurl) strcat(guidemlcmd,param.homeurl);
  2804.     if(param.homeurl) strcat(guidemlcmd,"\" ");
  2805.     if(param.prev) strcat(guidemlcmd,"PREV=\"");
  2806.     if(param.prev) strcat(guidemlcmd,param.prev);
  2807.     if(param.prev) strcat(guidemlcmd,"\" ");
  2808.     if(param.next) strcat(guidemlcmd,"NEXT=\"");
  2809.     if(param.next) strcat(guidemlcmd,param.next);
  2810.     if(param.next) strcat(guidemlcmd,"\" ");
  2811.     if(param.index) strcat(guidemlcmd,"INDEX=\"");
  2812.     if(param.index) strcat(guidemlcmd,param.index);
  2813.     if(param.index) strcat(guidemlcmd,"\" ");
  2814.     if(param.toc) strcat(guidemlcmd,"TOC=\"");
  2815.     if(param.toc) strcat(guidemlcmd,param.toc);
  2816.     if(param.toc) strcat(guidemlcmd,"\" ");
  2817.     if(param.help) strcat(guidemlcmd,"HELP=\"");
  2818.     if(param.help) strcat(guidemlcmd,param.help);
  2819.     if(param.help) strcat(guidemlcmd,"\" ");
  2820.     if(param.retrace) strcat(guidemlcmd,"RETRACE=\"");
  2821.     if(param.retrace) strcat(guidemlcmd,param.retrace);
  2822.     if(param.retrace) strcat(guidemlcmd,"\" ");
  2823.     if(param.home) strcat(guidemlcmd,"HOME=\"");
  2824.     if(param.home) strcat(guidemlcmd,param.home);
  2825.     if(param.home) strcat(guidemlcmd,"\" ");
  2826.     if(param.bar) strcat(guidemlcmd,"BAR=\"");
  2827.     if(param.bar) strcat(guidemlcmd,param.bar);
  2828.     if(param.bar) strcat(guidemlcmd,"\" ");
  2829.     if(param.bodyext) strcat(guidemlcmd,"BODY=\"");
  2830.     if(param.bodyext) strcat(guidemlcmd,param.bodyext);
  2831.     if(param.bodyext) strcat(guidemlcmd,"\" ");
  2832.     if(param.htmlheadf) strcat(guidemlcmd,"HTMLHEADF=\"");
  2833.     if(param.htmlheadf) strcat(guidemlcmd,param.htmlheadf);
  2834.     if(param.htmlheadf) strcat(guidemlcmd,"\" ");
  2835.     if(param.htmlfootf) strcat(guidemlcmd,"HTMLFOOTF=\"");
  2836.     if(param.htmlfootf) strcat(guidemlcmd,param.htmlfootf);
  2837.     if(param.htmlfootf) strcat(guidemlcmd,"\" ");
  2838.     if(param.cssurl) strcat(guidemlcmd,"CSS=\"");
  2839.     if(param.cssurl) strcat(guidemlcmd,param.cssurl);
  2840.     if(param.cssurl) strcat(guidemlcmd,"\" ");
  2841.     if(param.nohtml) strcat(guidemlcmd,"NOHTML ");
  2842.     if(param.images) strcat(guidemlcmd,"IMAGES ");
  2843.     if(param.footer) strcat(guidemlcmd,"FOOTER ");
  2844.     if(param.linkadd) strcat(guidemlcmd,"LINKADD=\"");
  2845.     if(param.linkadd) strcat(guidemlcmd,param.linkadd);
  2846.     if(param.linkadd) strcat(guidemlcmd,"\" ");
  2847.     if(param.nolink) strcat(guidemlcmd,"NOLINKS ");
  2848.     if(param.noemail) strcat(guidemlcmd,"NOEMAIL ");
  2849.     if(param.msdos) strcat(guidemlcmd,"MSDOS ");
  2850.     if(param.singlefile) strcat(guidemlcmd,"SINGLEFILE ");
  2851.     if(param.nonavbar) strcat(guidemlcmd,"NONAVBAR ");
  2852.     if(param.nomoznav) strcat(guidemlcmd,"NOMOZNAV ");
  2853.     if(param.showall) strcat(guidemlcmd,"SHOWALL ");
  2854.     if(param.wordwrap) strcat(guidemlcmd,"WORDWRAP ");
  2855.     if(param.smartwrap) strcat(guidemlcmd,"SMARTWRAP ");
  2856.     if(param.varwidth) strcat(guidemlcmd,"VARWIDTH ");
  2857.     if(param.noauto) strcat(guidemlcmd,"NOAUTO ");
  2858.     strcat(guidemlcmd,"\n");
  2859.  
  2860.  
  2861.     FPuts(fp,guidemlcmd);
  2862.  
  2863.     Close(fp);
  2864.  
  2865.     savetooltypes((STRPTR)filename,0);
  2866. }
  2867.  
  2868.  
  2869. void ui()
  2870. {
  2871.     long i=0; // temp variable
  2872.     struct List optlist;
  2873.     struct List navoptlist;
  2874.     struct List imgoptlist;
  2875.     struct List linkoptlist;
  2876.     struct List tablist;
  2877.     struct MsgPort *AppPort;
  2878.  
  2879.     struct Window *windows[WID_LAST];
  2880.     Object *objects[OID_LAST];
  2881.  
  2882.     UBYTE *opts[] = {"Auto","Wordwrap","Smartwrap","None",NULL};
  2883.     UBYTE *navopts[] = {"Header","Both","None",NULL};
  2884.     UBYTE *linkopts[] = {"Convert All","Not Email","Email Only","None",NULL};
  2885.     UBYTE *imgopts[] = {"Text","Images",NULL};
  2886.     UBYTE *tabs[] = {"Convert","Options",NULL};
  2887.         struct Menu *menustrip;
  2888.     UWORD menunum,itemnum,subnum; //menusel;
  2889.     struct MenuItem *item;
  2890.     int wrapm =0;
  2891.     int navm=0;
  2892.     int linkm=0;
  2893.  
  2894. if(param.noauto) wrapm = 3;
  2895. if(param.wordwrap) wrapm = 1;
  2896. if(param.smartwrap) wrapm = 2;
  2897. if(!param.noauto) wrapm = 0;
  2898.  
  2899. if(param.footer) navm = 1;
  2900. if(param.nonavbar) navm=2;
  2901.  
  2902. if(param.noemail) linkm=1;
  2903. if(param.nolink) linkm=linkm+2;
  2904.  
  2905. make_list(&optlist,opts);
  2906. make_list(&navoptlist,navopts);
  2907. make_list(&imgoptlist,imgopts);
  2908. make_list(&linkoptlist,linkopts);
  2909. maketablist(&tablist,tabs);
  2910.  
  2911.     if ( AppPort = CreateMsgPort() )
  2912.     {
  2913.         /* Create the window object.
  2914.          */
  2915.         objects[OID_MAIN] = WindowObject,
  2916.             WA_ScreenTitle, "GuideML " VERSIONSTR " (" VERSIONDATE ")",
  2917.             WA_Title, "GuideML",
  2918.             WA_Activate, TRUE,
  2919.             WA_DepthGadget, TRUE,
  2920.             WA_DragBar, TRUE,
  2921.             WA_CloseGadget, TRUE,
  2922.             WA_SizeGadget, TRUE,
  2923.             WA_SmartRefresh,TRUE,
  2924.             WA_IDCMP,IDCMP_MENUPICK,
  2925.             WINDOW_IconifyGadget, FALSE,
  2926.             WINDOW_IconTitle, "GuideML",
  2927.             WINDOW_AppPort, AppPort,
  2928.             WINDOW_Position, WPOS_CENTERMOUSE,
  2929.             WINDOW_ParentGroup, gadgets[GID_MAIN] = VGroupObject,
  2930.                 LAYOUT_SpaceOuter, TRUE,
  2931.                 LAYOUT_AddChild, gadgets[GID_TABS] = ClickTabObject,
  2932.                     GA_ID, GID_TABS,
  2933.                   GA_RelVerify, TRUE,
  2934.                   CLICKTAB_Labels,&tablist,
  2935.                       CLICKTAB_PageGroup, PageObject,
  2936.                         PAGE_Add,LayoutObject,
  2937.                             LAYOUT_AddChild,VGroupObject,
  2938.                                     LAYOUT_SpaceOuter,TRUE,
  2939.                                 LAYOUT_AddChild, gadgets[GID_FILE] = GetFileObject,
  2940.                                     GA_ID, GID_FILE,
  2941.                                     GA_RelVerify, TRUE,
  2942.                                     GETFILE_TitleText,"GuideML",
  2943.                                         GETFILE_Pattern,"#?.guide",
  2944.                                         GETFILE_DoPatterns,TRUE,
  2945.                                         GETFILE_ReadOnly,FALSE,
  2946.                                         GETFILE_FullFile,param.from,
  2947.                                 End,
  2948.                                 CHILD_Label, LabelObject,
  2949.                                 LABEL_Text, "_Input File",
  2950.                                 LabelEnd,
  2951.                                 CHILD_NominalSize, TRUE,
  2952.                                 LAYOUT_AddChild, gadgets[GID_TO] = GetFileObject,
  2953.                                     GA_ID, GID_TO,
  2954.                                     GA_RelVerify, TRUE,
  2955.                                     GETFILE_TitleText,"GuideML",
  2956.                                         GETFILE_DoSaveMode,TRUE,
  2957.                                         GETFILE_DrawersOnly,TRUE,
  2958.                                         GETFILE_ReadOnly,FALSE,
  2959.                                         GETFILE_Drawer,param.to,
  2960.                                 End,
  2961.                                 CHILD_Label, LabelObject,
  2962.                                 LABEL_Text, "_Output Path",
  2963.                                 LabelEnd,
  2964.                                 CHILD_NominalSize, TRUE,
  2965.                                 LAYOUT_AddChild, gadgets[GID_HOMEURL] = StringObject,
  2966.                                     GA_ID, GID_HOMEURL,
  2967.                                     GA_RelVerify, TRUE,
  2968.                                     STRINGA_TextVal,param.homeurl,
  2969.                                     STRINGA_MaxChars,100,
  2970.                                 End,
  2971.                                 CHILD_Label, LabelObject,
  2972.                                 LABEL_Text, "_Home URL",
  2973.                                 LabelEnd,
  2974.                                 CHILD_NominalSize, TRUE,
  2975.                                 LAYOUT_AddChild, gadgets[GID_FINDURL] = StringObject,
  2976.                                     GA_ID, GID_FINDURL,
  2977.                                     GA_RelVerify, TRUE,
  2978.                                     STRINGA_TextVal,param.findurl,
  2979.                                     STRINGA_MaxChars,100,
  2980.                                 End,
  2981.                                 CHILD_Label, LabelObject,
  2982.                                 LABEL_Text, "_Search URL",
  2983.                                 LabelEnd,
  2984.                                 CHILD_NominalSize, TRUE,
  2985.                                 LAYOUT_AddChild, gadgets[GID_CSS] = StringObject,
  2986.                                     GA_ID, GID_CSS,
  2987.                                     GA_RelVerify, TRUE,
  2988.                                     STRINGA_TextVal,param.cssurl,
  2989.                                     STRINGA_MaxChars,100,
  2990.                                 End,
  2991.                                 CHILD_Label, LabelObject,
  2992.                                 LABEL_Text, "CSS _URL",
  2993.                                 LabelEnd,
  2994.                                 CHILD_NominalSize, TRUE,
  2995.                                 LAYOUT_AddChild, gadgets[GID_LA] = StringObject,
  2996.                                     GA_ID, GID_LA,
  2997.                                     GA_RelVerify, TRUE,
  2998.                                     STRINGA_TextVal,param.linkadd,
  2999.                                     STRINGA_MaxChars,100,
  3000.                                 End,
  3001.                                 CHILD_Label, LabelObject,
  3002.                                 LABEL_Text, "_Link Prefix",
  3003.                                 LabelEnd,
  3004.                                 CHILD_NominalSize, TRUE,
  3005.                                 LAYOUT_AddChild, gadgets[GID_BODY] = StringObject,
  3006.                                     GA_ID, GID_BODY,
  3007.                                     GA_RelVerify, TRUE,
  3008.                                     STRINGA_TextVal,param.bodyext,
  3009.                                     STRINGA_MaxChars,100,
  3010.                                 End,
  3011.                                 CHILD_Label, LabelObject,
  3012.                                 LABEL_Text, "_Body",
  3013.                                 LabelEnd,
  3014.                                 CHILD_NominalSize, TRUE,
  3015.                                 LAYOUT_AddChild, gadgets[GID_HTMLHEADF] = GetFileObject,
  3016.                                     GA_ID, GID_HTMLHEADF,
  3017.                                     GA_RelVerify, TRUE,
  3018.                                     GETFILE_TitleText,"GuideML",
  3019.                                         GETFILE_Pattern,"#?.(s|%)htm(l|%)",
  3020.                                         GETFILE_DoPatterns,TRUE,
  3021.                                         GETFILE_ReadOnly,FALSE,
  3022.                                         GETFILE_FullFile,param.htmlheadf,
  3023.                                 End,
  3024.                                 CHILD_Label, LabelObject,
  3025.                                 LABEL_Text, "HTML H_eader",
  3026.                                 LabelEnd,
  3027.                                 LAYOUT_AddChild, gadgets[GID_HTMLFOOTF] = GetFileObject,
  3028.                                     GA_ID, GID_HTMLFOOTF,
  3029.                                     GA_RelVerify, TRUE,
  3030.                                     GETFILE_TitleText,"GuideML",
  3031.                                         GETFILE_Pattern,"#?.(s|%)htm(l|%)",
  3032.                                         GETFILE_DoPatterns,TRUE,
  3033.                                         GETFILE_ReadOnly,FALSE,
  3034.                                         GETFILE_FullFile,param.htmlfootf,
  3035.                                 End,
  3036.                                 CHILD_Label, LabelObject,
  3037.                                 LABEL_Text, "HTML _Footer",
  3038.                                 LabelEnd,
  3039.  
  3040.                                 LayoutEnd,
  3041.                             LayoutEnd,
  3042.                         PAGE_Add,LayoutObject,
  3043.                            LAYOUT_AddChild,VGroupObject,
  3044.                                LAYOUT_AddChild,HGroupObject,
  3045.                                      LAYOUT_AddChild,VGroupObject,
  3046.                                             LAYOUT_SpaceOuter,TRUE,
  3047.                                         LAYOUT_AddChild, gadgets[GID_WRAP] = ChooserObject,
  3048.                                             GA_ID, GID_WRAP,
  3049.                                             GA_RelVerify, TRUE,
  3050.                                           CHOOSER_PopUp,TRUE,
  3051.                                           CHOOSER_Labels,&optlist,
  3052.                                             CHOOSER_Selected,wrapm,
  3053.                                             CHOOSER_AutoFit,TRUE,
  3054.                                         ChooserEnd,
  3055.                                         CHILD_Label, LabelObject,
  3056.                                         LABEL_Text, "_Wrap mode",
  3057.                                         LabelEnd,
  3058.                                         CHILD_NominalSize, TRUE,
  3059.  
  3060.                                         LAYOUT_AddChild, gadgets[GID_NAVBAR] = ChooserObject,
  3061.                                             GA_ID, GID_NAVBAR,
  3062.                                             GA_RelVerify, TRUE,
  3063.                                           CHOOSER_PopUp,TRUE,
  3064.                                           CHOOSER_Labels,&navoptlist,
  3065.                                             CHOOSER_Selected,navm,
  3066.                                             CHOOSER_AutoFit,TRUE,
  3067.                                         ChooserEnd,
  3068.                                         CHILD_Label, LabelObject,
  3069.                                         LABEL_Text, "_Nav bar",
  3070.                                         LabelEnd,
  3071.                                         CHILD_NominalSize, TRUE,
  3072.  
  3073.                                         LAYOUT_AddChild, gadgets[GID_IMAGES] = ChooserObject,
  3074.                                             GA_ID, GID_IMAGES,
  3075.                                             GA_RelVerify, TRUE,
  3076.                                           CHOOSER_PopUp,TRUE,
  3077.                                           CHOOSER_Labels,&imgoptlist,
  3078.                                             CHOOSER_Selected,param.images,
  3079.                                             CHOOSER_AutoFit,TRUE,
  3080.                                         ChooserEnd,
  3081.                                         CHILD_Label, LabelObject,
  3082.                                         LABEL_Text, "_Style",
  3083.                                         LabelEnd,
  3084.                                         CHILD_NominalSize, TRUE,
  3085.  
  3086.                                         LAYOUT_AddChild, gadgets[GID_LINKS] = ChooserObject,
  3087.                                             GA_ID, GID_LINKS,
  3088.                                             GA_RelVerify, TRUE,
  3089.                                           CHOOSER_PopUp,TRUE,
  3090.                                           CHOOSER_Labels,&linkoptlist,
  3091.                                             CHOOSER_Selected,linkm,
  3092.                                             CHOOSER_AutoFit,TRUE,
  3093.                                         ChooserEnd,
  3094.                                         CHILD_Label, LabelObject,
  3095.                                         LABEL_Text, "_Links",
  3096.                                         LabelEnd,
  3097.                                         CHILD_NominalSize, TRUE,
  3098.  
  3099.                                         LAYOUT_AddChild, gadgets[GID_PREV] = StringObject,
  3100.                                             GA_ID, GID_PREV,
  3101.                                             GA_RelVerify, TRUE,
  3102.                                             STRINGA_TextVal,param.prev,
  3103.                                             STRINGA_MaxChars,100,
  3104.                                         End,
  3105.                                         CHILD_Label, LabelObject,
  3106.                                         LABEL_Text, "_Previous",
  3107.                                         LabelEnd,
  3108.                                             CHILD_NominalSize, TRUE,
  3109.                                         LAYOUT_AddChild, gadgets[GID_NEXT] = StringObject,
  3110.                                             GA_ID, GID_NEXT,
  3111.                                             GA_RelVerify, TRUE,
  3112.                                             STRINGA_TextVal,param.next,
  3113.                                             STRINGA_MaxChars,100,
  3114.                                         End,
  3115.                                         CHILD_Label, LabelObject,
  3116.                                         LABEL_Text, "Nex_t",
  3117.                                         LabelEnd,
  3118.                                             CHILD_NominalSize, TRUE,
  3119.                                         LAYOUT_AddChild, gadgets[GID_INDEX] = StringObject,
  3120.                                             GA_ID, GID_INDEX,
  3121.                                             GA_RelVerify, TRUE,
  3122.                                             STRINGA_TextVal,param.index,
  3123.                                             STRINGA_MaxChars,100,
  3124.                                         End,
  3125.                                         CHILD_Label, LabelObject,
  3126.                                         LABEL_Text, "Inde_x",
  3127.                                         LabelEnd,
  3128.                                             CHILD_NominalSize, TRUE,
  3129.                                         LAYOUT_AddChild, gadgets[GID_TOC] = StringObject,
  3130.                                             GA_ID, GID_TOC,
  3131.                                             GA_RelVerify, TRUE,
  3132.                                             STRINGA_TextVal,param.toc,
  3133.                                             STRINGA_MaxChars,100,
  3134.                                         End,
  3135.                                         CHILD_Label, LabelObject,
  3136.                                         LABEL_Text, "C_ontents",
  3137.                                         LabelEnd,
  3138.                                             CHILD_NominalSize, TRUE,
  3139.  
  3140.                                         LAYOUT_AddChild, gadgets[GID_HELP] = StringObject,
  3141.                                             GA_ID, GID_HELP,
  3142.                                             GA_RelVerify, TRUE,
  3143.                                             STRINGA_TextVal,param.help,
  3144.                                             STRINGA_MaxChars,100,
  3145.                                         End,
  3146.                                         CHILD_Label, LabelObject,
  3147.                                         LABEL_Text, "H_elp",
  3148.                                         LabelEnd,
  3149.                                             CHILD_NominalSize, TRUE,
  3150.  
  3151.                                         LayoutEnd,
  3152.  
  3153.                                    LAYOUT_AddChild,VGroupObject,
  3154.                                         LAYOUT_AddChild, gadgets[GID_VARWIDTH] = CheckBoxObject,
  3155.                                             GA_ID, GID_VARWIDTH,
  3156.                                             GA_RelVerify, TRUE,
  3157.                                             GA_Text,"_Variable Width Font",
  3158.                                             GA_Selected,param.varwidth,
  3159.                                             CHECKBOX_TextPlace,PLACETEXT_LEFT,
  3160.                                         CheckBoxEnd,
  3161.                                         CHILD_NominalSize, TRUE,
  3162.                                         LAYOUT_AddChild, gadgets[GID_MOZNAV] = CheckBoxObject,
  3163.                                             GA_ID, GID_MOZNAV,
  3164.                                             GA_RelVerify, TRUE,
  3165.                                             GA_Text,"_Mozilla Site Navigation Bar",
  3166.                                             GA_Selected,param.nomoznav+1,
  3167.                                             CHECKBOX_TextPlace,PLACETEXT_LEFT,
  3168.                                         CheckBoxEnd,
  3169.                                         CHILD_NominalSize, TRUE,
  3170.                                         LAYOUT_AddChild, gadgets[GID_SHOWALL] = CheckBoxObject,
  3171.                                             GA_ID, GID_SHOWALL,
  3172.                                             GA_RelVerify, TRUE,
  3173.                                             GA_Text,"Consistent _Across Pages",
  3174.                                             GA_Selected,param.showall,
  3175.                                             CHECKBOX_TextPlace,PLACETEXT_LEFT,
  3176.                                         CheckBoxEnd,
  3177.                                         CHILD_NominalSize, TRUE,
  3178.                                         LAYOUT_AddChild, gadgets[GID_MSDOS] = CheckBoxObject,
  3179.                                             GA_ID, GID_MSDOS,
  3180.                                             GA_RelVerify, TRUE,
  3181.                                             GA_Text,"MS-_DOS Compatible Filenames",
  3182.                                             GA_Selected,param.msdos,
  3183.                                             CHECKBOX_TextPlace,PLACETEXT_LEFT,
  3184.                                         CheckBoxEnd,
  3185.                                         CHILD_NominalSize, TRUE,
  3186.  
  3187.  
  3188.                                         LAYOUT_AddChild, gadgets[GID_NOHTML] = CheckBoxObject,
  3189.                                             GA_ID, GID_NOHTML,
  3190.                                             GA_RelVerify, TRUE,
  3191.                                             GA_Text,"Do Not Generate HTML _Headers",
  3192.                                             GA_Selected,param.nohtml,
  3193.                                             CHECKBOX_TextPlace,PLACETEXT_LEFT,
  3194.                                         CheckBoxEnd,
  3195.                                         CHILD_NominalSize, TRUE,
  3196.  
  3197.                                         LAYOUT_AddChild, gadgets[GID_SINGLEFILE] = CheckBoxObject,
  3198.                                             GA_ID, GID_SINGLEFILE,
  3199.                                             GA_RelVerify, TRUE,
  3200.                                             GA_Text,"S_ingle HTML File",
  3201.                                             GA_Selected,param.singlefile,
  3202.                                             CHECKBOX_TextPlace,PLACETEXT_LEFT,
  3203.                                         CheckBoxEnd,
  3204.                                         CHILD_NominalSize, TRUE,
  3205.  
  3206.                                         LAYOUT_AddChild, gadgets[GID_RETRACE] = StringObject,
  3207.                                             GA_ID, GID_RETRACE,
  3208.                                             GA_RelVerify, TRUE,
  3209.                                             STRINGA_TextVal,param.retrace,
  3210.                                             STRINGA_MaxChars,100,
  3211.                                         End,
  3212.                                         CHILD_Label, LabelObject,
  3213.                                         LABEL_Text, "_Retrace",
  3214.                                         LabelEnd,
  3215.                                             CHILD_NominalSize, TRUE,
  3216.                                         LAYOUT_AddChild, gadgets[GID_HOME] = StringObject,
  3217.                                             GA_ID, GID_HOME,
  3218.                                             GA_RelVerify, TRUE,
  3219.                                             STRINGA_TextVal,param.home,
  3220.                                             STRINGA_MaxChars,100,
  3221.                                         End,
  3222.                                         CHILD_Label, LabelObject,
  3223.                                         LABEL_Text, "H_ome",
  3224.                                         LabelEnd,
  3225.                                             CHILD_NominalSize, TRUE,
  3226.                                         LAYOUT_AddChild, gadgets[GID_FIND] = StringObject,
  3227.                                             GA_ID, GID_FIND,
  3228.                                             GA_RelVerify, TRUE,
  3229.                                             STRINGA_TextVal,param.find,
  3230.                                             STRINGA_MaxChars,100,
  3231.                                         End,
  3232.                                         CHILD_Label, LabelObject,
  3233.                                         LABEL_Text, "S_earch",
  3234.                                         LabelEnd,
  3235.                                             CHILD_NominalSize, TRUE,
  3236.                                         LAYOUT_AddChild, gadgets[GID_BAR] = StringObject,
  3237.                                             GA_ID, GID_BAR,
  3238.                                             GA_RelVerify, TRUE,
  3239.                                             STRINGA_TextVal,param.bar,
  3240.                                             STRINGA_MaxChars,10,
  3241.                                         End,
  3242.                                         CHILD_Label, LabelObject,
  3243.                                         LABEL_Text, "_Bar",
  3244.                                         LabelEnd,
  3245.                                             CHILD_NominalSize, TRUE,
  3246.  
  3247.                                         LayoutEnd,
  3248.                                     LayoutEnd,
  3249.                                 LayoutEnd,
  3250.                             LayoutEnd,
  3251.                         PageEnd,
  3252.                    ClickTabEnd,
  3253.  
  3254.                 LAYOUT_AddChild, HGroupObject,
  3255.                     GA_BackFill, NULL,
  3256.                     LAYOUT_SpaceOuter, FALSE,
  3257.                     LAYOUT_VertAlignment, LALIGN_CENTER,
  3258.                     LAYOUT_HorizAlignment, LALIGN_CENTER,
  3259.                           LAYOUT_AddChild, gadgets[GID_CONV] = ButtonObject,
  3260.                             GA_ID, GID_CONV,
  3261.                             GA_RelVerify, TRUE,
  3262.                             GA_Text,"_Convert",
  3263.                         ButtonEnd,
  3264.                 LayoutEnd,
  3265.                 CHILD_WeightedHeight, 0,
  3266.             EndGroup,
  3267.         EndWindow;
  3268.  
  3269.  
  3270.          /*  Object creation sucessful?
  3271.           */
  3272.         if (objects[OID_MAIN])
  3273.         {
  3274.             /*  Open the window.
  3275.              */
  3276.             if (windows[WID_MAIN] = (struct Window *) RA_OpenWindow(objects[OID_MAIN]))
  3277.             {
  3278.                 ULONG wait, signal, app = (1L << AppPort->mp_SigBit);
  3279.                 ULONG done = FALSE;
  3280.                 ULONG result;
  3281.                 UWORD code;
  3282.  
  3283.                     menustrip = addmenu(windows[WID_MAIN]);
  3284.  
  3285.                  /* Obtain the window wait signal mask.
  3286.                  */
  3287.                 GetAttr(WINDOW_SigMask, objects[OID_MAIN], &signal);
  3288.  
  3289.                 /* Input Event Loop
  3290.                  */
  3291.                 while (!done)
  3292.                 {
  3293.                     wait = Wait( signal | SIGBREAKF_CTRL_C | app );
  3294.  
  3295.                             if(wait & SIGBREAKF_CTRL_C)
  3296.                                 {
  3297.                         done = TRUE;
  3298.                                 }
  3299.                             else
  3300.                                 {
  3301.                         while ( (result = RA_HandleInput(objects[OID_MAIN], &code) ) != WMHI_LASTMSG )
  3302.                         {
  3303.                             switch (result & WMHI_CLASSMASK)
  3304.                             {
  3305.                                 case WMHI_CLOSEWINDOW:
  3306.                                     windows[WID_MAIN] = NULL;
  3307.                                     done = TRUE;
  3308.                                     break;
  3309.  
  3310.                                 case WMHI_MENUPICK:
  3311.                                         while (code !=MENUNULL)
  3312.                                         {
  3313.                                             //menusel = code;
  3314.                                             item = ItemAddress(menustrip,code);
  3315.                                             menunum = MENUNUM(code);
  3316.                                             itemnum = ITEMNUM(code);
  3317.                                             subnum = SUBNUM(code);
  3318.  
  3319.                                             switch(menunum)
  3320.                                             {
  3321.                                                 case 0:  // Project
  3322.                                                     switch(itemnum)
  3323.                                                     {
  3324.  
  3325.                                                         case 0: // save
  3326.                                                                     SetWindowPointer(windows[WID_MAIN],WA_BusyPointer,TRUE,WA_PointerDelay,TRUE,TAG_DONE);
  3327.                                                                      saveas();
  3328.                                                                     SetWindowPointer(windows[WID_MAIN],TAG_DONE);
  3329.                                                         break;
  3330.  
  3331.                                                         case 2: // about
  3332.  
  3333.                                                             err("GuideML "VERSIONSTR"\n\n© 1997-8 Richard Körber\nhttp://www.shredzone.de\n\n© 2001-4 Chris Young\nhttp://www.unsatisfactorysoftware.co.uk","OK",0);
  3334.                                                         break;
  3335.  
  3336.                                                         case 4: // quit
  3337.  
  3338.                                                         windows[WID_MAIN] = NULL;
  3339.                                                         done = TRUE;
  3340.  
  3341.                                                         break;
  3342.  
  3343.                                                     }
  3344.                                                 break;
  3345.  
  3346.                                                 case 1: // Settings
  3347.                                                     switch(itemnum)
  3348.                                                     {
  3349.                                                         case 0:
  3350.                                                          // save defaults
  3351.                                                                 SetWindowPointer(windows[WID_MAIN],WA_BusyPointer,TRUE,WA_PointerDelay,TRUE,TAG_DONE);
  3352.                                                          savetooltypes(defname,1);
  3353.                                                                 SetWindowPointer(windows[WID_MAIN],TAG_DONE);
  3354.                                                         break;
  3355.                                                     }
  3356.                                                 break;
  3357.  
  3358.  
  3359.                                             }
  3360.  
  3361.  
  3362.                                             code = item->NextSelect;
  3363.                                         }
  3364.                                         break;
  3365.  
  3366.                                 case WMHI_GADGETUP:
  3367.                                     switch (result & WMHI_GADGETMASK)
  3368.                                     {
  3369.                                         case GID_FILE:
  3370.                                             if(DoMethod((Object *)gadgets[GID_FILE],GFILE_REQUEST,windows[WID_MAIN]))
  3371.                                             {
  3372.                                                 GetAttr(GETFILE_FullFile,gadgets[GID_FILE],(ULONG*)¶m.from);
  3373.                                             }
  3374.  
  3375.                                           break;
  3376.  
  3377.                                         case GID_TO:
  3378.                                             if(DoMethod((Object *)gadgets[GID_TO],GFILE_REQUEST,windows[WID_MAIN]))
  3379.                                             {
  3380.                                                 GetAttr(GETFILE_Drawer,gadgets[GID_TO],(ULONG*)¶m.to);
  3381.                                             }
  3382.  
  3383.                                           break;
  3384.                                         case GID_HTMLHEADF:
  3385.                                             if(DoMethod((Object *)gadgets[GID_HTMLHEADF],GFILE_REQUEST,windows[WID_MAIN]))
  3386.                                             {
  3387.                                                 GetAttr(GETFILE_FullFile,gadgets[GID_HTMLHEADF],(ULONG*)¶m.htmlheadf);
  3388.                                             }
  3389.                                               if(param.htmlheadf)
  3390.                                                   {
  3391.                                                       if(strlen(param.htmlheadf)==0) param.htmlheadf=0;
  3392.                                                   }
  3393.  
  3394.                                           break;
  3395.                                         case GID_HTMLFOOTF:
  3396.                                             if(DoMethod((Object *)gadgets[GID_HTMLFOOTF],GFILE_REQUEST,windows[WID_MAIN]))
  3397.                                             {
  3398.                                                 GetAttr(GETFILE_FullFile,gadgets[GID_HTMLFOOTF],(ULONG*)¶m.htmlfootf);
  3399.                                             }
  3400.                                               if(param.htmlfootf)
  3401.                                                   {
  3402.                                                       if(strlen(param.htmlfootf)==0) param.htmlfootf=0;
  3403.                                                             }
  3404.                                           break;
  3405.  
  3406.                                         case GID_BODY:
  3407.                                               GetAttr(STRINGA_TextVal,gadgets[GID_BODY],(ULONG*)¶m.bodyext);
  3408.                                               if(strlen(param.bodyext)==0) param.bodyext=0;
  3409.                                         break;
  3410.                                         case GID_CSS:
  3411.                                               GetAttr(STRINGA_TextVal,gadgets[GID_CSS],(ULONG*)¶m.cssurl);
  3412.                                               if(strlen(param.cssurl)==0) param.cssurl=0;
  3413.                                         break;
  3414.                                         case GID_LA:
  3415.                                               GetAttr(STRINGA_TextVal,gadgets[GID_LA],(ULONG*)¶m.linkadd);
  3416.                                               if(strlen(param.linkadd)==0) param.linkadd=0;
  3417.                                         break;
  3418.                                         case GID_HOMEURL:
  3419.                                               GetAttr(STRINGA_TextVal,gadgets[GID_HOMEURL],(ULONG*)¶m.homeurl);
  3420.                                               if(strlen(param.homeurl)==0) param.homeurl=0;
  3421.                                         break;
  3422.  
  3423.                                         case GID_FINDURL:
  3424.                                               GetAttr(STRINGA_TextVal,gadgets[GID_FINDURL],(ULONG*)¶m.findurl);
  3425.                                               if(strlen(param.findurl)==0) param.findurl=0;
  3426.                                         break;
  3427.  
  3428.                                         case GID_RETRACE:
  3429.                                               GetAttr(STRINGA_TextVal,gadgets[GID_RETRACE],(ULONG*)¶m.retrace);
  3430.                                               if(strlen(param.retrace)==0) param.retrace=0;
  3431.                                         break;
  3432.  
  3433.                                         case GID_PREV:
  3434.                                               GetAttr(STRINGA_TextVal,gadgets[GID_PREV],(ULONG*)¶m.prev);
  3435.                                               if(strlen(param.prev)==0) param.prev=0;
  3436.                                         break;
  3437.  
  3438.                                         case GID_NEXT:
  3439.                                               GetAttr(STRINGA_TextVal,gadgets[GID_NEXT],(ULONG*)¶m.next);
  3440.                                               if(strlen(param.next)==0) param.next=0;
  3441.                                         break;
  3442.  
  3443.                                         case GID_INDEX:
  3444.                                               GetAttr(STRINGA_TextVal,gadgets[GID_INDEX],(ULONG*)¶m.index);
  3445.                                               if(strlen(param.index)==0) param.index=0;
  3446.                                         break;
  3447.  
  3448.                                         case GID_TOC:
  3449.                                               GetAttr(STRINGA_TextVal,gadgets[GID_TOC],(ULONG*)¶m.toc);
  3450.                                               if(strlen(param.toc)==0) param.toc=0;
  3451.                                         break;
  3452.  
  3453.                                         case GID_HELP:
  3454.                                               GetAttr(STRINGA_TextVal,gadgets[GID_HELP],(ULONG*)¶m.help);
  3455.                                               if(strlen(param.help)==0) param.help=0;
  3456.                                         break;
  3457.  
  3458.                                         case GID_FIND:
  3459.                                               GetAttr(STRINGA_TextVal,gadgets[GID_FIND],(ULONG*)¶m.find);
  3460.                                               if(strlen(param.find)==0) param.find=0;
  3461.                                         break;
  3462.  
  3463.                                         case GID_HOME:
  3464.                                               GetAttr(STRINGA_TextVal,gadgets[GID_HOME],(ULONG*)¶m.home);
  3465.                                               if(strlen(param.home)==0) param.home=0;
  3466.                                         break;
  3467.  
  3468.                                         case GID_BAR:
  3469.                                               GetAttr(STRINGA_TextVal,gadgets[GID_BAR],(ULONG*)¶m.bar);
  3470.                                         break;
  3471.  
  3472.                                         case GID_CONV:
  3473.                                             if(!param.from)
  3474.                                                 {
  3475.                                                     err("You must select an AmigaGuide\ndocument to convert!","OK",0);
  3476.                                                 }
  3477.                                                 else
  3478.                                                 {
  3479.                                                                 SetWindowPointer(windows[WID_MAIN],WA_BusyPointer,TRUE,TAG_DONE);
  3480.                                                     main(1,0);
  3481.                                                                   param.prev = textlabs.prev;
  3482.                                                                   param.next = textlabs.next;
  3483.                                                                   param.index = textlabs.index;
  3484.                                                                   param.toc = textlabs.toc;
  3485.                                                                   param.home = textlabs.home;
  3486.                                                                   param.help = textlabs.help;
  3487.                                                                   param.find = textlabs.find;
  3488.                                                                   param.retrace = textlabs.retrace;
  3489.                                                                   param.bar = textlabs.bar;
  3490.                                                                 SetWindowPointer(windows[WID_MAIN],TAG_DONE);
  3491.                                                 }
  3492.                                         break;
  3493.  
  3494.                                         case GID_WRAP:
  3495.  
  3496.                                                         switch(code)
  3497.                                                         {
  3498.                                                             case 0:
  3499.                                                                 param.noauto=0;
  3500.                                                                 param.wordwrap=0;
  3501.                                                                 param.smartwrap=0;
  3502.                                                                 SetAttrs(gadgets[GID_VARWIDTH],GA_Disabled,FALSE,TAG_DONE);
  3503.                                                                   RethinkLayout(gadgets[GID_VARWIDTH],windows[WID_MAIN],NULL,TRUE);
  3504.                                                             break;
  3505.  
  3506.                                                             case 1:
  3507.                                                                 param.wordwrap=TRUE;
  3508.                                                                 param.smartwrap=FALSE;
  3509.                                                                 param.noauto=TRUE;
  3510.                                                                 SetAttrs(gadgets[GID_VARWIDTH],GA_Disabled,FALSE,TAG_DONE);
  3511.                                                                   RethinkLayout(gadgets[GID_VARWIDTH],windows[WID_MAIN],NULL,TRUE);
  3512.                                                             break;
  3513.  
  3514.                                                             case 2:
  3515.                                                                 param.wordwrap=FALSE;
  3516.                                                                 param.smartwrap=TRUE;
  3517.                                                                 param.noauto=TRUE;
  3518.                                                                 SetAttrs(gadgets[GID_VARWIDTH],GA_Disabled,FALSE,TAG_DONE);
  3519.                                                                   RethinkLayout(gadgets[GID_VARWIDTH],windows[WID_MAIN],NULL,TRUE);
  3520.                                                             break;
  3521.  
  3522.                                                             case 3:
  3523.                                                                 param.wordwrap=FALSE;
  3524.                                                                 param.smartwrap=FALSE;
  3525.                                                                 param.noauto=TRUE;
  3526.                                                                 SetAttrs(gadgets[GID_VARWIDTH],GA_Disabled,TRUE,TAG_DONE);
  3527.                                                                   RethinkLayout(gadgets[GID_VARWIDTH],windows[WID_MAIN],NULL,TRUE);
  3528.                                                             break;
  3529.  
  3530.                                                         }
  3531.  
  3532.                                         break;
  3533.  
  3534.                                         case GID_VARWIDTH:
  3535.                                             param.varwidth=code;
  3536.                                         break;
  3537.  
  3538.                                         case GID_SINGLEFILE:
  3539.                                             param.singlefile=code;
  3540.                                             if(param.singlefile)
  3541.                                             {
  3542.                                                 SetAttrs(gadgets[GID_LA],GA_Disabled,TRUE,TAG_DONE);
  3543.                                                 //RethinkLayout(gadgets[GID_LA],windows[WID_MAIN],NULL,TRUE);
  3544.                                             }
  3545.                                             else
  3546.                                             {
  3547.                                                 SetAttrs(gadgets[GID_LA],GA_Disabled,FALSE,TAG_DONE);
  3548.                                                 //RethinkLayout(gadgets[GID_LA],windows[WID_MAIN],NULL,TRUE);
  3549.                                             }
  3550.  
  3551.  
  3552.  
  3553.                                         break;
  3554.  
  3555.                                         case GID_NOHTML:
  3556.                                             param.nohtml=code;
  3557.                                         break;
  3558.  
  3559.                                         case GID_NAVBAR:
  3560.  
  3561.                                                         switch(code)
  3562.                                                         {
  3563.                                                             case 0:
  3564.                                                                 param.nonavbar=FALSE;
  3565.                                                                 param.footer=FALSE;
  3566.                                                                 SetAttrs(gadgets[GID_IMAGES],GA_Disabled,FALSE,TAG_DONE);
  3567.                                                                   RethinkLayout(gadgets[GID_IMAGES],windows[WID_MAIN],NULL,TRUE);
  3568.                                                             break;
  3569.  
  3570.                                                             case 1:
  3571.                                                                 param.nonavbar=FALSE;
  3572.                                                                 param.footer=TRUE;
  3573.                                                                 SetAttrs(gadgets[GID_IMAGES],GA_Disabled,FALSE,TAG_DONE);
  3574.                                                                   RethinkLayout(gadgets[GID_IMAGES],windows[WID_MAIN],NULL,TRUE);
  3575.                                                             break;
  3576.  
  3577.                                                             case 2:
  3578.                                                                 param.nonavbar=TRUE;
  3579.                                                                 param.footer=FALSE;
  3580.                                                                 SetAttrs(gadgets[GID_IMAGES],GA_Disabled,TRUE,TAG_DONE);
  3581.                                                                   RethinkLayout(gadgets[GID_IMAGES],windows[WID_MAIN],NULL,TRUE);
  3582.                                                             break;
  3583.                                                         }
  3584.  
  3585.                                         break;
  3586.  
  3587.                                         case GID_LINKS:
  3588.  
  3589.                                                         switch(code)
  3590.                                                         {
  3591.                                                             case 0:
  3592.                                                                 param.noemail=FALSE;
  3593.                                                                 param.nolink=FALSE;
  3594.                                                             break;
  3595.  
  3596.                                                             case 1:
  3597.                                                                 param.noemail=TRUE;
  3598.                                                                 param.nolink=FALSE;
  3599.                                                             break;
  3600.  
  3601.                                                             case 2:
  3602.                                                                 param.noemail=FALSE;
  3603.                                                                 param.nolink=TRUE;
  3604.                                                             break;
  3605.  
  3606.                                                             case 3:
  3607.                                                                 param.noemail=TRUE;
  3608.                                                                 param.nolink=TRUE;
  3609.                                                             break;
  3610.                                                         }
  3611.                                         break;
  3612.  
  3613.                                         case GID_IMAGES:
  3614.                                             param.images=code;
  3615.                                         break;
  3616.  
  3617.                                         case GID_MOZNAV:
  3618.                                             param.nomoznav=code+1;
  3619.                                         break;
  3620.  
  3621.                                         case GID_SHOWALL:
  3622.                                             param.showall=code;
  3623.                                         break;
  3624.  
  3625.                                         case GID_MSDOS:
  3626.                                             param.msdos=code;
  3627.                                         break;
  3628.  
  3629.                                     }
  3630.                                     break;
  3631.  
  3632.                                 case WMHI_ICONIFY:
  3633.                                     RA_Iconify(objects[OID_MAIN]);
  3634.                                     windows[WID_MAIN] = NULL;
  3635.                                     break;
  3636.  
  3637.                                 case WMHI_UNICONIFY:
  3638.                                     windows[WID_MAIN] = (struct Window *) RA_OpenWindow(objects[OID_MAIN]);
  3639.  
  3640.                                     if (windows[WID_MAIN])
  3641.                                     {
  3642.                                         GetAttr(WINDOW_SigMask, objects[OID_MAIN], &signal);
  3643.                                     }
  3644.                                     else
  3645.                                     {
  3646.                                         done = TRUE;    // error re-opening window!
  3647.                                     }
  3648.                                      break;
  3649.                             }
  3650.                         }
  3651.                     }
  3652.                 }
  3653.             }
  3654.  
  3655.             /* Disposing of the window object will also close the window if it is
  3656.              * already opened, and it will dispose of the layout object attached to it.
  3657.              */
  3658.             DisposeObject(objects[OID_MAIN]);
  3659.         }
  3660.  
  3661.         DeleteMsgPort(AppPort);
  3662.     }
  3663. free_list(&optlist);
  3664. freetablist(&tablist);
  3665. FreeMenus(menustrip); // menu
  3666. cleanup(0);
  3667.  
  3668. /*
  3669.     closelibs();
  3670.  
  3671.     return(0);
  3672. */
  3673.  }
  3674.  
  3675.  
  3676. void free_list(struct List *list)
  3677. {
  3678.     struct Node *node,*nextnode;
  3679.     node = list ->lh_Head;
  3680.     while (nextnode = node->ln_Succ)
  3681.     {
  3682.         FreeChooserNode(node);
  3683.         node=nextnode;
  3684.     }
  3685.     NewList(list);
  3686. }
  3687.  
  3688. void freetablist(struct List *list)
  3689. {
  3690.     struct Node *node,*nextnode;
  3691.     node = list ->lh_Head;
  3692.     while (nextnode = node->ln_Succ)
  3693.     {
  3694.         FreeClickTabNode(node);
  3695.         node=nextnode;
  3696.     }
  3697.     NewList(list);
  3698. }
  3699.  
  3700. BOOL make_list(struct List *list, UBYTE **labels1)
  3701. {
  3702.     struct Node *node;
  3703.     WORD i = 0;
  3704.     int ro=FALSE;
  3705.  
  3706.     NewList(list);
  3707.  
  3708.     while (*labels1)
  3709.     {
  3710.  
  3711.         if (node = AllocChooserNode(
  3712.                             CNA_Text, *labels1,
  3713.                             CNA_ReadOnly, ro,
  3714.                         TAG_DONE))
  3715.         {
  3716.             AddTail(list, node);
  3717.         }
  3718.         else
  3719.             break;
  3720.  
  3721.         labels1++;
  3722.         i++;
  3723.         ro=FALSE;
  3724.     }
  3725.     return(TRUE);
  3726. }
  3727.  
  3728. BOOL maketablist(struct List *list, UBYTE **labels1)
  3729. {
  3730.     struct Node *node;
  3731.     WORD i = 0;
  3732.  
  3733.     NewList(list);
  3734.  
  3735.     while (*labels1)
  3736.     {
  3737.  
  3738.         if (node = AllocClickTabNode(
  3739.                             TNA_Text, *labels1,
  3740.                             TNA_Number, i,
  3741.                         TAG_DONE))
  3742.         {
  3743.             AddTail(list, node);
  3744.         }
  3745.         else
  3746.             break;
  3747.  
  3748.         labels1++;
  3749.         i++;
  3750.     }
  3751.     return(TRUE);
  3752. }
  3753.  
  3754. struct Menu *addmenu(struct Window *win)
  3755. {
  3756.  
  3757.  
  3758. APTR vi;
  3759.     struct Menu *menustrip;
  3760.     struct NewMenu menu[] = {
  3761.                                       {NM_TITLE,"Project"           , 0 ,0,0,0,},
  3762.                                       { NM_ITEM,"Save As..."        ,"S",0,0,0,},
  3763.                                       { NM_ITEM,NM_BARLABEL         , 0 ,0,0,0,},
  3764.                                       { NM_ITEM,"About..."          ,"A",0,0,0,},
  3765.                                       { NM_ITEM,NM_BARLABEL         , 0 ,0,0,0,},
  3766.                                       { NM_ITEM,"Quit"              ,"Q",0,0,0,},
  3767.                                       {NM_TITLE,"Settings"          , 0 ,0,0,0,},
  3768.                                       { NM_ITEM,"Save As Defaults"   ,"D",0,0,0,},
  3769.                                       {  NM_END,0,0,0,0,0,},
  3770.                                      };
  3771.  
  3772.     menustrip = CreateMenus(menu,GTMN_FullMenu,TRUE,TAG_DONE);
  3773.     vi = GetVisualInfoA(win->WScreen,TAG_DONE);
  3774.     LayoutMenus(menustrip,vi,GTMN_NewLookMenus,TRUE,TAG_DONE);
  3775. //                SetAttrs(win,WINDOW_MenuStrip,menustrip,TAG_DONE);
  3776.   SetMenuStrip(win,menustrip);
  3777.  
  3778. return(menustrip);
  3779. }
  3780.  
  3781.  int err(char *errtxt,char *gadgtxt,int fail)
  3782. {
  3783.     int rc;
  3784.  
  3785.     if(intuitionbase)
  3786.     {
  3787.         struct EasyStruct errorreq =
  3788.             {
  3789.             sizeof(struct EasyStruct),
  3790.             0,
  3791.             "GuideML",
  3792.             errtxt,
  3793.             gadgtxt
  3794.             };
  3795.         rc = EasyRequest(NULL,&errorreq,NULL);
  3796.     }
  3797.     else
  3798.     {
  3799.         printf("%s\n",*errtxt);
  3800.     }
  3801.     if (fail) cleanup(fail);
  3802.  
  3803.     return(rc);
  3804. }
  3805.  
  3806. void cleanup(int fail)
  3807. {
  3808.     if(ttfrom) FreeMem(ttfrom,strlen(ttfrom)+1);
  3809.     if(ttto) FreeMem(ttto,strlen(ttto)+1);
  3810.     if(tthomeurl) FreeMem(tthomeurl,strlen(tthomeurl)+1);
  3811.     if(ttfindurl) FreeMem(ttfindurl,strlen(ttfindurl)+1);
  3812.     if(ttprev) FreeMem(ttprev,strlen(ttprev)+1);
  3813.     if(ttnext) FreeMem(ttnext,strlen(ttnext)+1);
  3814.     if(ttindex) FreeMem(ttindex,strlen(ttindex)+1);
  3815.     if(tttoc) FreeMem(tttoc,strlen(tttoc)+1);
  3816.     if(tthelp) FreeMem(tthelp,strlen(tthelp)+1);
  3817.     if(ttretrace) FreeMem(ttretrace,strlen(ttretrace)+1);
  3818.     if(tthome) FreeMem(tthome,strlen(tthome)+1);
  3819.     if(ttfind) FreeMem(ttfind,strlen(ttfind)+1);
  3820.     if(ttbar) FreeMem(ttbar,strlen(ttbar)+1);
  3821.     if(ttbody) FreeMem(ttbody,strlen(ttbody)+1);
  3822.     if(tthtmlheadf) FreeMem(tthtmlheadf,strlen(tthtmlheadf)+1);
  3823.     if(tthtmlfootf) FreeMem(tthtmlfootf,strlen(tthtmlfootf)+1);
  3824.     if(ttcss) FreeMem(ttcss,strlen(ttcss)+1);
  3825.  
  3826. if(GadToolsBase)
  3827. {
  3828.     #ifdef __amigaos4__
  3829.     DropInterface((struct Interface *)IGadTools);
  3830.     #endif
  3831.  
  3832.     CloseLibrary(GadToolsBase);
  3833. }
  3834. if(UtilityBase)
  3835. {
  3836.     #ifdef __amigaos4__
  3837.     DropInterface((struct Interface *)IUtility);
  3838.     #endif
  3839.  
  3840.     CloseLibrary(UtilityBase);
  3841. }
  3842.  
  3843.     #ifndef __amigaos4__
  3844.     {
  3845.      if(WindowBase) CloseLibrary(WindowBase);
  3846.      if(LayoutBase) CloseLibrary(LayoutBase);
  3847.      if(ButtonBase) CloseLibrary(ButtonBase);
  3848.      if(CheckBoxBase) CloseLibrary(CheckBoxBase);
  3849.      if(LabelBase) CloseLibrary(LabelBase);
  3850.      if(ChooserBase) CloseLibrary(ChooserBase);
  3851.      if(ClickTabBase) CloseLibrary(ClickTabBase);
  3852. //     if(IntegerBase) CloseLibrary(IntegerBase);
  3853. //     if(ListBrowserBase) CloseLibrary(ListBrowserBase);
  3854.      if(GetFileBase) CloseLibrary(GetFileBase);
  3855.      if(StringBase) CloseLibrary(StringBase);
  3856.      if(GadToolsBase) CloseLibrary(GadToolsBase);
  3857.      if(IconBase) CloseLibrary(IconBase);
  3858.  
  3859.     #endif
  3860.  
  3861.  if(aslbase) CloseLibrary(aslbase);
  3862.  if(dosbase) CloseLibrary(dosbase);
  3863.  if(intuitionbase) CloseLibrary(intuitionbase);
  3864. }
  3865.  
  3866.  exit(fail);
  3867.  }
  3868.